Jan 6

As defined before, the each segment will have it’s own battery pack using NiMH cells. In order to define the best option for charging them, I will investigate the application note from ATMEL to see if this concept can be used.

When reading thought the application note I wrote down some items:

  • NiMH batteries are charged with a constant current of 1*C
  • To determine if the battery is full, dV/dt is used with temperature and absolute voltage as backup
  • Trickle charging is done using a current of 0.025*C for maximum 90 minutes
  • Charging is allowed between 5 and 40 dC
  • Maximum voltage is 1.5V per cell
  • Charging is stopped if dV/dt is 0 and/or dT/dt is 0

In any case the charger can not exceed 1A so that approx 15 segments can charge in parallel. This would already mean a power supply that can deliver 16A at roughly 10V so 160W. A current source is easy to build using a PNP transistor or even a LM317, however they both have a problem in dissipating the over voltage, specially when the battery is empty. In that case the regulator must dissipate 10-(5*1.1)=4.5V*1A=4.5W which will require some kind of heat sink.

A better option is to use some kind of PWM based current source, to prevent power being dissipated (and so wasted). This is indeed what the application note uses also in a very elementary form, it basically increases the voltage over the battery while measuring the current. If the current is too high, the PWM frequency is lowered so that a storage capacitor is charged less and in return the voltage is reduced.

This would mean a loop in software that continuously measure the current and adjusts the PWM. Since the current will not vary rapidly this does not have to be done extremely fast and non-interruptible. There are two micro controllers discussed in the application note which both use the same principle but with a different PWM frequency. The lower the frequency, this higher the storage capacity must be and the higher the switching coil must be. I tend to use so higher frequency, but this needs further investigation.

For measuring the current a series resistor is used 0.25E and the voltage drop over the resistors is measured. It might be an option to use this as well for measuring the discharge current, for this it will be needed to measure positive (charge goes in) and negative (charge goes out) voltages. This could be done using an amplifier that amplifies the voltage drop with an offset but perhaps a smarter one is to measure the voltage just before the resistor and directly after the resistor just before the battery and in software subtract the two measured voltages. This has the benefit that the exact voltage of the battery is known as well allowing a second option for cutting of the charger or the consumer in case the battery is almost empty.

Some calculations:

  • The AT90CAN has a 10-bit ADC, using the internal 2.56V reference this gives a resolution of 2.5mV per bit
  • Using a 0.25E resistor and a voltage drop of 2.5mV this means a resultion of 10mA

With the resolution of 10mA per bit this means a current range of 0..10.24A, this is an overkill by a factor of at least 4. The 10mA will also not be 10mA due to noise and tolerances, typically the first bit should be ignored giving an resolution of 20mA. If the factor of 4 somehow can be used this can be decreased to 5mA which is a very nice resolution. Question is how to multiple the drop by a factor of 4?

One option is to increase the resistor to 1.0E. At the maximum discharge current of (estimated) 2.5A this will result in a voltage drop of 2.5V which is not nice… The other option is to use the amplifier again, in that case we still need to measure two voltages; one is the drop of the resistor and one is the actual battery voltage to see if it is almost empty.

I have to admit that analogue design is not my strongest point so designing this amplifier + offset circuit will go with some trial and error although the basics of OPAMPs are known to me. The most simple model I always use is that an OPAMP tries to match the voltage on the + input and on the – input. If they don’t match it will increase the output voltage if the + voltage is higher than the – voltage and reduce the output voltage if the – voltage is higher than the + voltage.

We need an difference amplifier as indicated on page 3 of the basics, in theory this is nothing else than an non-inverting amplifier with the difference that the ground to which Vout is increased is no longer the fixed ground but now a variable ground. Problem still is that Vout can only follow the positive voltage drops. Assume V1=V2=0V, than Vout is 0V. Assume V2=1V, than Vout is increase until the voltage on the – input is the same voltage as on the + input. Assume V2=-1V, than Vout should decrease the voltage but that is not possible with only a positive voltage supply. So the trick here is to generate a Vout of (2.56/2)=1.28V when V1=V2. Since Vout is increased this means that the voltage on the + input must be 1.28V in this case, so in short, we must add 1.28V to V2 or substract 1.28V from V1.

Assume R1=R2=R3=R4=100E, than when V1=V2=5V the output voltage should be 1.28V. As a result, V- is (((5-1.28)/(100+100))*100)+1.28=3.14V. That means that V+ is 3.14V as well (remember the amplifier tries to make them the same). The current through R3 is than (5-3.14)/100=0.0186A and the voltage drop over R4 must than be 100*0.0186=1.86V requiring the ground not to be 0V but 3.14-1.86=1.28V. That is funny, the 1.28V “virtual ground” matches exactly the offset of 1.28V…..

The amplification factor is given by R2/R1 if R1=R3 and R2=R4. Using a 0.1E resistor with a current of 2.5A results in a voltage drop of 0.25V. If we use 1.1V as the voltage to measure at 2.5A this means a multiplication factor of 1.1/0.25=4.4 times. The impedance “seen” by the 0.1E resistor should be very high to prevent influence of the voltage drop by the measurement circuit. Something in the range of 200 to 400k should be OK (gut feeling). When the resolution must be 10mA by not using the least significant bit this would mean a maximum measured current of (1024/2/2)=256*10mA=2.560A (+ and -). Using a resistor of 0.1E will cause a voltage drop of 0.256V at the maximum current. This should translate into 1.28V offset to “the virtual ground” at the output of the amplifier so a multiplication factor of 1.28/0.256=5.00 times.

Although above schematic looks simple there are some problems to solve:

  • The 1.28V voltage supply should be able to sink current instead of supplying it
  • The 1.28V voltage should be 50% of the internal 2.56V reference in the AT90CAN

An amplifier can source and sink current, so that can be used for the 1.28V power supply. The 50% can be created by using that same amplifier wired as the image below.

Since R3=R4 the V+ is 1.28V, the output is shorted to the V- and the rule dictates that the amplifier increases the output voltage until V- is V+ hence the 1.28V output. The 2.56V is available inside the AT90CAN but not outside so this can not be used. Instead an external reference diode needs to be used for generating this voltage in which case it can also be applied to the AT90CAN so that we are sure we the offset is always 50% of Vref.

One thing to keeo in mind is that most amplifiers can not generate an output voltage above Vdd-1.5V, some of them can (rail-to-rail amplifiers) but most of them don’t. They can also not work with voltages on V+ and V- that are above Vdd-1.5V, so if the 0.1E resistor was to be connected to the plus of the battery which produces 5*1.2=6.0V and the amplifier is running at 5V you can not work with the voltage drop over the 0.1E resistor since one side is 6.0V and the other side a little bit less; both more than 5-1.5=3.5V. Instead the 0.1E resistor should be connected to the minus of the battery which results in a “virtual” negative ground. This will become clear later.

Jan 4

The snake will consist of many segments that are in principle all the same as previously defined when investigating possible battery solutions. Each block needs to be investigated further, let’s start with the servo that will act as the muscles. I have no idea what kind of force the servo must be capable of producing. I can try to make some educated guess, but perhaps the most practical is to use the ones with the highest force and get hands-on experience of the actual torque generated during movements. Searching the internet shows the most simple one is T=Kt*I were the Kt stands for Torque Constant and I for the current but there is a lot of discussion on this.

Searching thought the many, many servo’s at Conrad, there are two main topic to decide upon. Since a servo works with a small DC-engine and a gearbox, the way to increase torque is to make the gearbox ratio larger. As a result, the possible torque is increased but the turning speed is decreased. Second topic is the material used for the gears and bearings. If it is plastic, at high torque the teeth of the gears will simply snap. Same for the bearing but than more wearing out of the bearings that finally leads to the problem that only the top of a tooth is used from the gear which again results in breaking the teeth.

For speed, there are special servo’s used for controlling the lines of a sailing boat. For example the SW1200 can supply a lot of torque (115Ncm) but are slow (1.6sec for 360 degrees or 0.26sec for 60 degrees). Since they can turn 360 degrees it seems there is no stop and they can spin around several times which makes sense if you are pulling a line. Improving speed will decrease torque to 72Ncm but increases the speed to 0.1sec for 60 degrees.

I worked with the AK-12digital servo’s in the past, they provide a torque of 160Ncm and a speed of 0.2sec for 60 degrees and I was not impressed with the torque they delivered. The most powerful servo that Conrad has available is the RS-1501 that provides 180Ncm of torque and a speed of 0.2sec for 60 degrees, I’m not sure this is enough.

Another option is to use a DC-motor and a gearbox in combination with some position measurement. Based on a snakes vertebrae, it can make an angle of + or – 20 degrees compare to the next. However, my vertabraes will be longer so this should be a bit bigger, assume + and – 40 degrees. Than moving forward using a sinus pattern were  ones per second the servo would go from far left to far right would mean a minimum speed 1 sec per 80 degrees or 0.75 sec for 60 degrees.

While writing this (and that is exactly why I write this) it might also be an option to use the SW1200 and add an extra gear on to of it to reduce the speed by a factor of (0.75/0.26)=3. That would mean the circumference of the large gear would be 3 times larger than the small gear. Assume the small gear has a radius of 1 than the circumference is 2*PI*1=2*PI. Than the large one has a circumference of 6*PI so the radius is 2*PI*R=6*PI, so R=3…. Force = mass * arm length, so when the radius is 3 times longer than the force that can be applied is also 3 times longer. Normally the force is less when the arm is longer but here the gear reduction reduction increases the force. Not sure that all above is correct but this would mean that the than the force of 115Ncm can be increased to 345Ncm.

The other option is to use the RS-1501 in combination with an extra gear. The speed is 0.2 sec for 60 degrees so the reduction can be (0.75/0.2)=3.75 or 3 for short. Than using above assumption the force can be increased by 3 to a massive 540Ncm. It would require a modification of the servo since it can not turn 360 degrees but that should not be a problem. Most of them use a potentiometer connected to the axe of the final gear to give position feedback. It would be simple to use a new potentiometer for the larger gear and feed this back to the original control. Since this servo also uses metal gears and bearings I will order one to do some initial experiments.

Jan 1

I like LED’s that indicate activity, also here a 90 degrees bended version should be used. Next to this, the type to be used should be a low current version to reduce the amount of power consumed. There are various types available, in 3mm and in 5mm. They use 2mA of current compared to normally 10 or 20, they 5mm versions have an extra mechanical snap which I guess is good for robots that run around all the time, so I will uses the 5mm versions for now.

There are two signals to monitor; the CAN frames that are send by the PMC and are address to the PMC and the commands from and to the FOXBoard. For the first one, the ATDVK90CAN1 board has two LED’s tied directly to the TXD and the RXD lines. This is not what I want since in that case it shows any CAN frame while I’m only interested in RoboCAN commands that are processed by the PMC. This will require an extra out of the AT90CAN and a software modification in the RoboCAN library. The second one is already implemented.

For the micro controller, there are three AT90CAN’s available were the main difference is in memory and price:

  • AT90CAN32, 32KB Flash, 2KB SRAM and 1KB EEPROM, 6.89 EUR at 10 units
  • AT90CAN64, 64KB Flash, 4KB SRAM and 2KB EEPROM, 7.36 EUR at 10 units
  • AT90CAN128, 128KB Flash, 4KB SRAM and 4KB EEPROM, 11.92 EUR at 10 units

The safest choice in life is always the middle one, I guess also here. Compiling the Primary Motor Cortex basic implementation that can interface with the FOXBoard and has the full RoboCAN protocol added uses 20KB of Flash and 1.6KB of SRAM. The AT90CAN32 can be used if not much additional application is added that uses variables as well. For only 0.47 EUR you can twice the amount of SRAM and FLASH, so I guess that is not worth taking the risk that the application just runs out of memory which would mean removing the part and soldering a larger on on the board. Time consuming and you risk damaging the board.

The cost adder for the AT90CAN128 is significant while only increasing the amount of FLASH. At the time of writing this, the number of code lines are:

  • CAN.c, 576 lines
  • RoboCAN.c, 885 lines
  • FOXBoard.c, 340 lines
  • Primary Motor Cortex, 213 lines

Lines of code do not directly translate to number of bytes, but for a rough estimation of how many lines the application can contain it will do: (20KB/(576+885+340+213))=10 bytes per line. 44KB/10=4500 lines of code. The largest application I wrote contained 3530 lines of code and there I was close to of-loading sub-systems to secondary micro controllers due to the complexity of the product. So using the AT90CAN64 is a safe choice for the PMC.

In order to connect the JTAG to the AT90CAN64 a 2×5 header needs to be used. Also here a 90 degrees bended version should be used so that any code can be updated later or any micro controller can be debugged later while no parts of SnakeBot have to be disassembled.

Combining all above results in the first version of the schematic. I will develop the PCB later, first the schematic should be on my desk for some days to review it several times.