I’ve been writing many, many iterations of both the software (the controller) after updating the platform (sensors+chassis) itself to have an additional ultrasonic sensor looking backward. So now, when I rotate the ultrasonic sensor, I read values in front (right side, angle looking right, looking forward and at angle to the left) and towards the back (left-side, side angle looking backward towards the left, angle straight on towards the back and angle looking backward towards the right).
So six values in total… Having the servo rotate the sensors is necessary right now so as not to go over budget on the digital pins of the Arduino Dueminalove board as each of the two sensors require two signal cable (one for trigger and one for echo).
I’ve done many changes and many tests but I’m not yet satisfied with the controller for that particular configuration and I still have ideas that I need to implement to make the robot behavior interesting…
However, in the meantime, I’m also preparing for the next platform. I’m thinking of designing a circuit to select one ultrasonic sensor at a time out of four. Since two sensors cannot be triggered simultaneously (they would interfere with each other) I would want to trigger one at a time and then wait for the echo.
To help with that task, I’ve discovered two wonderful OpenSource software:
- Fritzing: a very good design software that lets you design breadboard, schematic and final PCB layout with a library of parts (or very easy to create custom parts) in an optimized workflow
- Logic Gate Simulator: create and test logic gates design
For Fritzing, I also took the time to create a custom part for the HC-SR04 Ultrasonic Sensor. I’ve done so by first drawing vector graphics for the breadboard view, schematic view and PCB board in Inkscape. I then created a new part, imported the just created images and then placing connections “squares” overlaid on the imported images. Relatively easy, but I spent a lots of time getting the fonts right before discovering that the easiest way was to convert all text to paths (Path > Object to Path).
I’ve uploaded the HC-SR04 Fritzing part in the relevant “user-contributed parts” bug if you need it.
For Logic Gate Simulator, I first wrote down the truth table for the sensor selector (“when pin1 and pin2 are at 1, send trigger signal to sensor4 and receive echo from sensor4″) and tested it, but I’m unsure on how to proceed next in terms of buying the necessary IC that would provide me with the AND/NOT logic gate that I need.
I also have to investigate how to change the simplistic Ultrasonic code that’s been provided with the sensors to instead generate interrupts so I don’t have to block the Arduino loop while waiting for the echo to come back. Same for getting the “stop now” button to actually work!