Mixed Reality Board
September 03, 2010, 09:42:04 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Welcome to the official Mixed-Reality forum!

If you have problems to register, please mail to h/dot/spille/at/gmail/dot/com
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Expected Improvements  (Read 1976 times)
guerra
AsadaLabs
Full Member
*
Posts: 109



View Profile WWW
« on: March 25, 2008, 06:13:31 pm »

I notice I never really wrote about the expected improvements in the new hardware in detail, so I will try to comment some important points here.

Here is a table with some comparisons

Old
New
ProcessorsSingle processor:
     
  • PIC PIC18F1220 @ 4MHz
     
Two processors:
     
  • ARM AT91SAM7X256 @ 18.432MHz
  • AVR ATtiny84 @ 8MHz
Program Memory (flash)
  • 4K
  • 256K (ARM) & 8K (AVR)
RAM
  • 256bytes
  • 65K (ARM) & 512bytes (AVR)
Infrared module     
  • Receiver only,
  • filtered carrier freq @ 40kHz
  • max of about 5kbps
     
  • Can receive and transmit,
  • IrDA pulse encoding,
  • max of 115.2kbps
     
Compiler
  • Proprietary MPLAB C18
  • C language
     
  • Open source GNU GCC
  • C/C++ languages
     
Debugging line by line     
  • Windows
  • using proprietary MPLAB
     
     
  • Linux,
  • Windows and
  • Mac
  • using Open source Eclipse
     
Uploader     
  • Proprietary MPLAB programmer
     
     
  • Standard JTAG programmer (ARM)
  • Standard SPI programmer (AVR)
  • Implementing USB or infrared uploader
    is also theoricaly possible for the ARM
  • It is also possible to make the ARM upload
    firmware to the AVR
     
Batteries
  • (1x)100mAh
  • (2x)190mAh
Wheel radius
(this influences the resulting
linear velocity given the same
angular velocity)
  • Around 5mm
  • Around 10mm

Based on the table above one can already expect there should a big leap in performance. Let's examine some details

Speed

It may sound strange, but in this micro-robot more speed necessarily ends up consuming more CPU power. The reason for that is because we do not use DC motors, we use watch stepper motors. This eliminates the need for encoders, since you can calculate exactly how much the wheel has turned. But in order to make the stepper motor spin one has to switch the polarity of a series of magnets in such a way so that the axis of the motor spins forward and rest into the next stable position, then we say the motor moved one step.

In practice this means one has to send a pre-determined binary sequence directly into the four pins that drive the internal electro-magnets that make the wheel spin. The problem is that this motor set implements a massive reduction ratio of 1:240 in order to achieve the necessary torque to drag the robot body. This means the RPM at the shaft of the wheel is 240 slower than the actual speed of the stepper motor.

The frequency within which the processor switches the binary pattern to the wheels will ultimately determine the wheel speed and in a fast processor this can theoretically be implemented by using interrupts and a timer. In practice, however, the PIC18F1220 running at 4MHz takes so long to save and restore context into the stack and move the execution of the program fulfill the interrupt request that the wheel ends up spinning at an unbearably slow speed. So in the end we needed to implement the spinning of the wheels in the main loop of the program.

Another major issue is that the robot is so massive for the delicate motors and the reduction ratio is so huge that it starts creating an inertial effect as speed increases. In practice this means one cannot instantaneously start spinning a wheel at a high velocity without accelerating it slowly first. Then once at this high speed the pace of the stepper control has to be kept constant. One simple longer delay between any given two steps and the motor gets stuck and has to be accelerated again in order to recover its original speed. Since the spinning of the wheels had to be in the main loop in the older robot, whenever one wants to do something else, other than spinning the wheels stopping the wheels was unavoidable. This is the main reason why the old robots "shake" when they receive infrared commands. They are actually stopping, parsing the infrared command, and then resuming their work. As a software attempt to reduce the impact of the slow speed supported by the robots I implemented the so-called nitro speeds. The nitro command is a subroutine that temporarily disables all interrupts and carefully accelerates the wheels to achieve the absolute maximum rotation speed. While rotating at this speed any small jitter causes one or both wheels to lock in place, this is the reason why the infrared listening is deactivated during that window. Since the nitro was tuned pushing the motor/processor performance to its extreme maximum, sometimes one may experience the unfortunate locking of one wheel or another, therefore resulting in the outcome trajectory of a quick spin even when the command was supposed to dash forward.

In the new robot there is an exclusive AVR micro-controller dedicated only to speed control. This AVR controller has twice the speed and twice the memory than the previous PIC micro-controller of the older version. Moreover, this AVR controller will not have to spend CPU time parsing incoming data because it will receive commands directly from the other processor through an SPI port. The AVR has support for SPI protocol implemented in its hardware, meaning the receiving can be done in parallel and an interrupt request is only generated when the data is already available.

We truly hope the AVR micro-controller will thus be able to produce a more fine-grained range of consistent rotation speeds by actually implementing the stepper control via timers, as it should be.

Infrared

The older version of the robot has a kind of infrared receiver module very commonly used in house appliances. This module has an internal filter damping heavily any infrared signal outside the nominal frequency of 40kHz. This means this sensor returns a low voltage only when it senses a series of pulses coming at the specified frequency, otherwise it returns a high voltage (inverted logic). The actual data bits are encoded by variating delays of the the low voltage (pulses@40kHz) and the high voltage (no IR).

For example, the bit 1 could be encoded by 200ms of pulses @ 40kHz followed by 200ms of nothing and the bit 0 by 200ms of pulses @ 40kHz followed 400ms of nothing. The more the pulsing interval gets shortened, the less robust is the response of the sensor. Moreover, the parsing of the signal needs to be done via software, therefore wasting CPU time during the length of a command. One could trade-off command length in ms in exchange for spare time to allow context switching so that parsing could be done via interrupts. The problem is that commands have to be received at a minimum reasonable frame-rate in order to allow the robots to be controlled online in real-time.

Ordinary computers do not have hardware for implementing this type of encoding, so the 40kHz pulse generation has to be done in the computer side as well either by using some sort of kernel module such as LIRC or by acquiring some external device, like IRTrans.

The new robot has an IrDA transceiver, and the ARM micro-controller has a hardware IrDA modulator/de-modulator. The physical transmission of IrDA data is done via pulse encoding (as oposite to delay encoding). The IrDA modulation basically transforms square waves into pulses at their rising edges and can be implemented automatically by the processor. Both sending and receiving use the standard UART interfaces which also have hardware implementation of receiving and sending, meaning that the programmer has only to worry about the logic of the data received, letting the hardware deal with the timings and modulations.

Both the ARM processor and the IrDA module are said to support the maximum transfer speed of 115.2kbps therefore allowing much faster frame rates and more dense information exchange. This means longer commands can be used and nicer error checking methods can be implemented. Moreover, the intrinsic value of a missed command decreases when the frame-rate is higher.

For the computer no special software is needed, the IrDA transceiver will simply be seen as another serial device. The robot can also send information to the computer, as long as some software based collision detection & avoidance is implemented (all robots share the same physical layer)

We also want to allow the implementation of a more flexible protocol in this new robot, supporting both broadcasting and also addressed modes. In broadcasting all robots receive all commands and each robot just picks the information pertinent to itself from the chunk of data (mask out the rest) and execute it. This is because sending ids and parsing them is too much overhead and error prone when you just want to set wheel speeds. On the other hand, more intelligent commands could be eventually sent by addressing a specific robot in addressed mode. Examples could range from controlling the acceleration profile of the wheel all the way up to setting color segmentation parameters in a robot equipped with a camera.

« Last Edit: March 25, 2008, 08:42:07 pm by guerra » Logged
StefanKrupop
Wolves
Jr. Member
*
Posts: 52


View Profile
« Reply #1 on: March 26, 2008, 05:01:06 am »

Here is a table with some comparisons

Old
New
ProcessorsSingle processor:
     
  • PIC PIC18F1220 @ 4MHz
     
Two processors:
     
  • ARM AT91SAM7X256 @ 18.432MHz
  • AVR ATtiny84 @ 8MHz


One small addition:
As the ARM processor has an inbuilt PLL circuit (and now also the necessary external components Wink), the processor speed can be set to up to 48MHz by software.

Stefan
Logged
guerra
AsadaLabs
Full Member
*
Posts: 109



View Profile WWW
« Reply #2 on: March 31, 2008, 06:22:32 pm »

Oh really? I had not realized that before... when you talked to me about the components I thought you needed to get it running up to 18.432 MHz... but 48MHz is amazing. Just Today I studied over the internet what exactly the PLL does... I should have known these things...

Is 48MHz the exact value?
Logged
StefanKrupop
Wolves
Jr. Member
*
Posts: 52


View Profile
« Reply #3 on: March 31, 2008, 08:08:36 pm »

Is 48MHz the exact value?

No, but in order to use the USB pheripheral a frequency of about 48MHz (with a small margin) is required. The chip is specified for up to 55MHz, but thanks to the PLL almost any frequency is possible because the clock is first divided and then multiplied by an integer number.

Stefan
Logged
guerra
AsadaLabs
Full Member
*
Posts: 109



View Profile WWW
« Reply #4 on: April 07, 2008, 10:13:39 am »

I thought it would make sense to comment in this post a bit about the problems in the parsing of infrared commands.

The old robots had to parse each command by polling, and they could not spin the wheels while doing that. Since the command could not be shorter than a few hundred milliseconds this resulted in a noticeable halt. In the new robot there will be a slave processor controlling the wheel speed and this processor will just get very raw wheel speeds already parsed from the infrared command received in the ARM processor (e.g. two bytes each cycle). The data is not only shorter, but it is also sent quicker, with timings in the range of that of the CPU clocking, and the data is received via hardware, so an interrupt is only generated when a whole byte is already available in some register (no need to parse dynamically the stream of data while it comes). In the ARM processor the parsing is more complicated than that because it needs to be robust against corrupted data (because of infrared noise) and also because it needs to listen to all data coming via infrared and decide what data was addressed to this robot and what data wasn't. But even doing so, the ARM should be quicker than the old robot and since it is a completely different processor this happens in a completely different thread, not influencing the control of the wheels done in the AVR.

In the old robots it is possible to have them not stopping between commands if you implement both infrared receiving and motor control via interrupt based timers. But in order to make that possible you need to reduce drastically the speed of the wheels and increase drastically the length of the infrared commands. From my experience trying that I would imagine the robot would end up having to turn the wheels at around 1 rpm and receive commands at a maximum of around 3fps, which is unbearably slow for any practical application.

Actually this is the main reason why it took me more than four months just to write the firmware in these old robots (despite the fact that I never wrote a whole firmware before). I struggled a lot trying all alternatives to solve the problem, but the speeds were always unacceptable, so I ended up with the dirty solution of polling both motor and infrared and doing either one at a time.
« Last Edit: April 07, 2008, 10:15:50 am by guerra » Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!