Stybb

Stybb

A Customer SAMrI built by Mike Davies.

I originally fitted the Q3, Q4 & Q5 detectors, but they only seemed to detect things up to about 3 cms away, and cause a lot more battery drain, so I disconnected Q3 & Q5.

The main mod concerns the ultra-sonic detectors. I fitted a Devantech SRF04 and SRF05 - only fitted different ones because that's what I had here. These will detect anything from 2cm up to about 3 metres (well out of the Doyho), so in software I tend to treat anything over about 50cm as out-of-range. Two sensors are used to get some idea whether the target is to the left or right without having to twist and turn.

At less than 2cm, readings can get inconsistent, so that's where Q4 comes into it's own. If Q4 is triggered I ignore what the ultrasonics say, and just plough forward.

These ultra-sonic gadgets return the distance to target as a timed pulse - anything from 100uS to 38mS; this is different to the Sharp devices which generate an variable analogue voltage. Having two sensors causes a problem in that there is only one pin on the AVR capable of timing input pulse, so the outputs from both sensors are OR'd together in a 74HC32 and brought to ICP1 (PB0). The sensors are triggered from PC4 & PC5 alternately, so even though the outputs are OR'd together there's no confusion about which one the result is for. All this additional hardware is mounted (with hot melt glue) on an aluminium plate which is also there to protect the SAMrI PCB from damaged during a contest. See photo.

Conventionally, the AVR input capture is used with timer1, but, timer1 is being used for the motor PWM, and it cannot be used on SAMrI for input capture. Therefore the software simulates another 16bit counter to be used with the ICP by using Timer2 and counting the overflows, and use this counter instead of the ICR1 register.

The LEDs provide some indication of what the SAMrI is thinking about. On powerup is makes a pretty count-down timer, but when running, from top to bottom it displays, moving forward, Q4 detect, turn left, turn right, right sensor closest, left sensor closest, right sensor out of range, left sensor out of range.

I acquired the LED's when a friend of a friend had a clear-out. Thay are like standard 5mm LEDs, with a domed top, but they have flat sides and stack on a 0.1" matrix pitch. Useful for arrays, but as I've said, never seen them for sale anywhere. Iwired them up wrongly, so the 390R SIL pulls each to 5V, so to switch the LED on I have to output a zero, which is backwards to my way of thinking. So in the code I just do everything like I want and then at the crucial moment do a PORTC ~= portc; type thing.

The LEDs are useful for debugging, but if I was starting again, I'd output stuff to a Nokia 3310 display. I've only just discovered how easy it is to use these Nokia displays, and there's libraries of routines available for the AVR freely available on the WWW. The display only cost £2.50 inc p+p off eBay.

With all the extra electronics and LEDs I upgraded to 5V regulator to a 1A version.

Software is 875 bytes.

SAMrI Mini Sumobot Stybb

SAMrI Mini Sumobot Stybb

SAMrI Mini Sumobot Stybb