The system uses two magnets embedded in the white center gear to trigger a Hall Effect Sensor (2 triggers = 1 gear revolution). The sensitivity of the sensor can be adjusted by the blue potentiometer on the HES Logic Board. The Arduino Pro Mini (3.3v, do not try and program it as a 5v device!) times how long each revolution takes and then averages the last 5 readings to get a stable RPM figure. The Arduino is connected to the Drivetrain Team Raspberry Pi via 4 wires: GND, 5V, SDA, SCL. You should recognize that as the I2C communication bus. Via this bus, the RPi asks the Arduino for an RPM value and the Arduino replies with its current RPM reading. The code running on the Arduino is attached below, in case you were curious - you don't really need to know too much about it if your only goal is implementing it in your system.
It doesn't matter what message you send the Arduino - it will always respond with the RPM number. Now, on to the sending side - the Raspberry Pi. Talking to the Arduino is very simple via I2C. The code I used below sends whatever number the user inputs in the Pi to the Arduino and then waits for a reply.
Yes, I'm providing the code as a jpeg. I'm evil. When this code runs, it returns the RPM number to the RPi. Once you have that number, you're gonna want to convert to MPH and then serve it up to the Android App. If you have any questions, please ask in the comments or email me if it's urgent.

No comments:
Post a Comment