Keeping Up With the MicroBros – Week 11


Do you ever feel like you’re trapped in the endless problems that arise during system integration, desperately seeking a way to get everything working? ​:cold_sweat::sweat_drops: Well, buckle up because today, we’re diving deep into the endless abyss of integrating subsystems in the real-world. ​:skull_crossbones::broken_heart:

Jonathan ​:man_mage:

Today I’ve realized the minima and maxima methods of determining when a turn is finished will not work in all cases, and must therefore reconsider how we deal with turns.

We can’t really rely on the micro:bit’s compass, as this does not seem to function if the device isn’t laying horizontally. A method in CODAL exists to compensate for this called tiltCompensatedBearing, but it does not seem to function well.

Also, we have figured out an interval in where we can trust the ultrasonics. This is [ 4 – 30 ] cm. This means we can only detect walls reliably 1-2 tiles away.

ALSO, since the IR sensors are working and built in to the car we can use them to regulate to stay in the middle of maze tiles! Here in action:

Mats ​:technologist:

IR sensors ​:light_bulb_off:

Another week, more progress and problems. On Monday Iver finished up attaching all the sensors to the frame and gave it over to me to figure out how to get it working. I hacked together a crude IR sensor driver, a bandpass implementation I stole copied from StackOverflow and attributed under the license, and using some of the facilities in the nRF52833 and CODAL like the ADC and effects (signal processing). The drives does sampling at 4800Hz by default.

Setup of ADCs and emitter in IR driver

I noticed our IR setup seems to measure different values based on material, my assumption is this is due to the reflective properties of the material, nevertheless I just made a crude way of calibrating sensors and used a wooden plate I had at hand. Our effective range of measurement (from wheels) is around 0-6cm. Luckily the width of our car + 6 cm on each side is still quite shorter than the 16cm wide maze tiles and seems to be sufficient!

State machine for running ​:man_running:

While Jonathan was busy tuning the PID controller ​:octagonal_sign::anger::anger_right: with the IR sensors I started working on the control flow ​:man_surfing: and states of the robot ​:robot: .

For now there are four states:

  • Uninitialized (Wait for sensors and then find start direction and move)
  • MoveStraight (We move straight in either direction)
  • MoveTurn (Doing a wide turn to get into a side)
  • Stopped (Just a state that will indefinitely spin on stopping the motors for now, useful for testing)

As our chonker​:pregnant_man: of a car is too wide to turn in place we need to do wide turns and pretty much have to start the turn as soon as detected ​:sweat: .

Another problem is that if we hit a dead end we cannot turn, so we have to “reverse”, but we thought ahead and have an ultrasonic sensor both in “front” and “back” ​:muscle::brain: meaning we don’t really have a real forward and backwards ​:open_mouth: , by letting a simple boolean dictate what is considered forward and then correct for it in all code sensing and acting it would be like the car just instantly rotated 180 degrees. ​:magic_wand:

Iver ​:older_man:

This week the car is finished. The IR and ultrasonic sensors are in place and soldiered the way they should be.

IR Sensor Schematic

We decided that the emitters would just use one analogue outputs from the micro:bit. So I plugged pin 0 in parallel. The schematic shows the rest of the circuit. After this process I have learned the basics of another discipline, witch has been a fun experience. And I hope I have managed to make the balance in a purely computer engineer group a bit easier despite that I did not know what I was doing in the beginning.


Leave a Reply