Updates on the lightsaber prop
In this article I will explain some of the main features of the new lightsaber PCB design and some of my thoughts behind them. I will also give some updates on the other aspects of the lightsaber project.
Schematic changes
Power distribution
While trying to work out how the lightsaber would be powered, I found out that the LED strip consumed 70mA even when all of the pixels were off. Since the plan was to program the lightsaber to go into a low-power mode if it was inactive, this presented a problem. Even if the Nano and the audio amplifier were completely shut down, the lightsaber would still consume power until it was switched off. This also would have required a more expensive switch, since the switch would have to be able to switch the full current of the LEDs.
To fix this, I added a MOSFET which could turn the power to the LED strip on and off. I also separated the LED and Arduino/amplifier grounds. This allows the Arduino to be powered through the protection circuit on the battery charger board and through a cheaper, lower-current switch and the LEDs to be powered directly from the battery. If the battery protection circuit cuts off power to the Arduino, or the user opens the switch, then the MOSFET turns off and the LEDs are also disconnected.
A simplified schematic showing just the changes to the power distribution is shown below:
Audio amplifier
In the first version of the board design, I included a voltage divider in the feedback path of the first op-amp, as shown below:The idea was that the audio amplifier would operate at a higher voltage than the rest of the circuitry so it could produce louder sound. The first op amp would then scale the output of the DAC up to the supply voltage to the amplifier. However, since the sound produced running at battery voltage is already loud enough, and fitting a boost converter would be infeasible, this feature was eliminated. This freed up board space and will reduce the future potential for confusion and assembly errors.
I also changed the input to the inverting amplifier that drives the second half of the full bridge from the output of the first half of the full bridge to the output of the DAC. This will have no effect on the sound quality or volume, but it will reduce the standby power consumption. Previously, when the DAC was powered off, its output would be pulled low by a weak internal pull-down resistor. This would drive the first half of the half bridge low and the second half high (due to the inverting action of the inverting amplifier). However, this causes current to flow through the resistors in the inverting amplifier, increasing the power consumption. With the new design, the resistors in the inverting amplifier override the weak pull-down in the DAC, putting both half-bridges at half the supply voltage. Thus, no current flows in the inverting amplifier resistors.
PCB changes
LED connection
Since the high-current pathway that powers the LEDs must now flow through the MOSFET mounted on the board, the board had to be modified to accomodate these connections. For improved current handling capability, I used traces on the top and bottom layersin parallel when connecting the LED connector, the MOSFET, and the power input connector.
Grounds and decoupling
I added capacitor C7 to filter noise coming from the PWM switching of the LED strip. The traces are arranged such that current must flow past the connector, which further decreases the amount of noise coupled back into the rest of the circuitry.
In general, I tried to arrange the capacitors on the board such that the current must flow past the capacitor to get to the load. Thus, any noise generated by the load will be filtered by the capacitor before it can return to the source. This seems to be effective in preventing electrical noise from the LEDs or from the vibrator from affecting the audio amplifier.
Minimizing power consumption
When the lightsaber detects that it has not moved in a while, it should enter a low-power mode to minimize battery drain. To do this, the lightsaber follows the following procedure:
- The Arduino Nano switches off power to the LEDs by setting the control output (digital pin 3) high.
- The Arduino Nano sends the shut-down command to the ATtiny.
- The Arduino Nano drives the MISO input to the ATtiny low. This pin is used to later wake the ATtiny up again.
- The Arduino Nano goes into power-down mode.
- The ATtiny stops the timer for generating the audio signals and commands the DAC to enter shut-down mode.
- The ATtiny goes into power-down mode.
However, despite powering down nearly everything, the board still consumes around 13 milliamps. I tried removing the regulator, which reduced power consumption to around 12mA. The LED accounts for about 2.2mA, so the remaining 9.8mA are likely down to the serial to USB converter chip.
Measuring battery voltage
The battery voltage can be determined by using the Arduino Nano's ADC to measure its supply rail. To do this, the ADC is configured to use the supply rail as a reference. The input to the ADC is then set to the internal 1.1V analog reference. Then, the output of the ADC will be equal to 1024 * (1.1V / Vsup)
. Solving for the supply voltage, we get Vsup = 1126400mV / ADC_output
. The actual formula was determined to be around Vsup = 1129000mV / ADC_output
.
Current plans for the V2 design
Currently, I am waiting on some parts to arrive, so I have listed here some of the things I plan to work on soon.
- Collision detection: I would like to be able to detect when the blade of the lightsaber has collided with something, so the lightsaber can play a sound effect and flash the LEDs.
- Battery state sensing: I would like to be able to determine the current state of charge of the battery. Measuring the voltage supplied to the Arduino is rather straightforward, as explained above. The state of charge can also be easily determined from the open circuit voltage of the battery. However, the voltage of the battery drops under load, and it will be necessary to compensate for this drop in order to accurately determine the state of charge. The amount of drop is proportional to the battery's internal resistance and the LED setting, but the internal resistance changes with the state of charge and with the age of the battery. This is further complicated by the fact that when the load on the battery changes, the voltage does not immediately drop to the new value, but instead approaches it slowly. I will likely use a lookup table of internal resistances that is calibrated when the lightsaber's LEDs turn on and off.
- FLASH programming: I would like the kids assembling the project to be able to change the sound files stored on the FLASH chip without removing the FLASH chip from the board and putting it in an external programmer. Since not all of the SPI lines are connected to the Nano, the ATtiny will have to relay information from the Nano to the SPI flash. Ideally, the user will have to upload a special programming sketch to the Nano, which sends a command to the ATtiny that puts it into SPI programming mode. The ATtiny will then receive the information in chunks, which it can then write to the SPI flash.
Potential changes for a future V3 design
One change I might make in the future would be to allow the Arduino to access all of the SPI lines rather than just MISO and CLK, as well as allow the Arduino to drive the reset line of the ATtiny. This would allow the Arduino to act as a programmer for the ATtiny and for the SPI FLASH. It would then not be necessary to remove the FLASH chip or the ATtiny and put it an external programmer to reprogram them. Instead, the user could upload a sketch to the Nano and communicate via it to the ATtiny or the FLASH.
Another useful feature would be some kind of built in current sensing capability. Initially, I planned to use the Rds(on) of the MOSFET as a current sensing shunt, but the drain to source voltage was too low to be measured, even when the LEDs were at full brightness. Thus, a future design might have some kind of current sensing shunt, either as an external component or in the form of a PCB trace. This might also require a slightly larger board, since I had trouble fitting everything on as it is.
I would also like to connect at least one of the accelerometer's interrupt lines to an input on the Arduino Nano. This would allow the accelerometer to wake the Arduino when the lightsaber is moved afte a longer period of inactivity.
Comments
Post a Comment