Jump to content

Adding a digital speedometer into a generic EU


Jacky Heshi

Recommended Posts

Hello I was wondering if I can add a Arduino nano, to measure the hall sensor in the unicycle and display the pulse with a digital display.

There is five wires connected to the Hall sensor, does anyone know which one is measured for rpm? 

I really want to know the speed of the unicycle without using a bike speedometer or GPS speedometer. 

Link to comment
Share on other sites

38 minutes ago, Jacky Heshi said:

Hello I was wondering if I can add a Arduino nano, to measure the hall sensor in the unicycle and display the pulse with a digital display.

There is five wires connected to the Hall sensor, does anyone know which one is measured for rpm? 

I really want to know the speed of the unicycle without using a bike speedometer or GPS speedometer. 

You could probably get away with monitoring only one of those, but you could monitor at least two sensors, preferably three to get more precise measurements. The two "extra" wires are the power and ground for the sensors. I don't think there's any general color coding for them (could be wrong, though?), so you'd need to measure first which one(s) give the signal, and if you want to use more than one, the order in which they turn on/off (there will be points where two adjacent sensors are triggered at the same time). Then you'd need to measure how many "cycles" the sensors do (there are 6 steps per direction before it starts over) per one revolution of the motor, measure the tire circumference and calculate the speed from that information.

 

Link to comment
Share on other sites

2 hours ago, Lisny Abby said:

speed of the unicycle? use your phone app, i think it can do this.

Maybe the wheel doesn't have an App access or the speed shown is not trustable. Go with a bicycle spedometer. Seen this on some occasions. You can calibrate this devices for your tire size.

Link to comment
Share on other sites

9 hours ago, esaj said:

You could probably get away with monitoring only one of those, but you could monitor at least two sensors, preferably three to get more precise measurements. The two "extra" wires are the power and ground for the sensors. I don't think there's any general color coding for them (could be wrong, though?), so you'd need to measure first which one(s) give the signal, and if you want to use more than one, the order in which they turn on/off (there will be points where two adjacent sensors are triggered at the same time). Then you'd need to measure how many "cycles" the sensors do (there are 6 steps per direction before it starts over) per one revolution of the motor, measure the tire circumference and calculate the speed from that information.

 

One sensor is enough, the hall sensor output is very clean (digital, with no rebound since the hall sensor has a strong hysteresis). Two is needed only if you want to take into account... riding in reverse.

Black is ground, red is 5V (to power the hall sensors), the 3 other colors are with same coding as the 3 power wires but it's not important since you need just one.

On my Airwheel, IIRC, there are 48 pulses per revolution. On my 16" Firewheel, 56 pulses/rev.

To count them, just connect a voltmeter, power up the wheel, push it gently and see the signal alternating between 0V and 5V. Easy peasy to process with an Arduino. I even have some Attiny13 programmed to convert the pulses to one count/rev so you can connect it to a bike computer (to replace the bike computer's clumsy magnet & ILS), I will give it away, just mail me.

 

Link to comment
Share on other sites

40 minutes ago, OliverH said:

Maybe the wheel doesn't have an App access or the speed shown is not trustable.

Lol, "not trustable", Gotway is notorious for it. The speed displayed in its app is "exagerated" (to use kind word) of about +20%.

Link to comment
Share on other sites

1 hour ago, hobby16 said:

One sensor is enough, the hall sensor output is very clean (digital, with no rebound since the hall sensor has a strong hysteresis). Two is needed only if you want to take into account... riding in reverse.

Black is ground, red is 5V (to power the hall sensors), the 3 other colors are with same coding as the 3 power wires but it's not important since you need just one.

On my Airwheel, IIRC, there are 48 pulses per revolution. On my 16" Firewheel, 56 pulses/rev.

To count them, just connect a voltmeter, power up the wheel, push it gently and see the signal alternating between 0V and 5V. Easy peasy to process with an Arduino. I even have some Attiny13 programmed to convert the pulses to one count/rev so you can connect it to a bike computer (to replace the bike computer's clumsy magnet & ILS), I will give it away, just mail me.

 

1

So basically this idea is not only for myself but also for my Robotics course in high school.

I was thinking, having an arduino to count the rev//secound and display the speed with a 7 second display.

Seems like you know what you are talking about, so do you have any tips to go about this? 

My robotics teacher said I might cause some noise to the Hall sensor by paralleling one of the signal wire.

Link to comment
Share on other sites

1 hour ago, hobby16 said:

Lol, "not trustable", Gotway is notorious for it. The speed displayed in its app is "exagerated" (to use kind word) of about +20%.

Psst ;) I haven't named Gotway or Kingsong (same code base). It would be so easy to change it.

Link to comment
Share on other sites

11 hours ago, Jacky Heshi said:

So basically this idea is not only for myself but also for my Robotics course in high school.

I was thinking, having an arduino to count the rev//secound and display the speed with a 7 second display.

Seems like you know what you are talking about, so do you have any tips to go about this?

It's really not hard, just do it.

 

11 hours ago, Jacky Heshi said:

My robotics teacher said I might cause some noise to the Hall sensor by paralleling one of the signal wire.

NO! The hall sensor is digital and hence immune to noise (heck, want noise ? look at what the motor generates already !), so there is no risk whatsoever to connect it in parallel to an INPUT of the Arduino. You can even connect a long wire to take the signal out of the wheel up to the arduino in your hand and the signal will still be pristine.

Link to comment
Share on other sites

Phone tracking apps are 'GPS' based, aka cell tower based... And not always reliable, consistant, get black out, or people just don't own smartphones, a bike speedometer is easy to attach if you find a means to attaching a magnet to wheel and not lose magnet... Bluetooth sensors do work, just don't buy the 'wireless' ones, don't have range and perfect alignment is needed...

Link to comment
Share on other sites

@Jacky Heshi I will help you doing that if you share the source code and some text and pictures of the final result.

I am just measuring that using our OpenSource firmware firmware but I also like your idea!!

With your board and the hall sensor signal, your will be able to perfectly measure the speed. The input pin of Arduino should not create any relevant noise.

Please see our wiki where you will get many tecnhical details of generics EUCs: https://github.com/generic-electric-unicycle/documentation/wiki

Link to comment
Share on other sites

10 hours ago, electric_vehicle_lover said:

@Jacky Heshi I will help you doing that if you share the source code and some text and pictures of the final result.

I am just measuring that using our OpenSource firmware firmware but I also like your idea!!

With your board and the hall sensor signal, your will be able to perfectly measure the speed. The input pin of Arduino should not create any relevant noise.

Please see our wiki where you will get many tecnhical details of generics EUCs: https://github.com/generic-electric-unicycle/documentation/wiki

 

Sure! Would love to! We have the whole spring break to do this.

I have a TG-T3 which is considered as a generic EU. Instead of counting the pluses, I went on your site and counted the amount of magnetics around the circumference of the wheel. So the TG-T3 will have 46 pulses per revolution.

generic_EUC-motor-02.jpg

Link to comment
Share on other sites

  • 1 month later...

Here is what i go so far, but need need help with the code, the code can pick up the readings from the hall sensor, but the speed its displaying never resets back to zero

 

 

 

 

#include <LiquidCrystal.h>

LiquidCrystal lcd(11, 9, 6, 5, 4, 3);  // LCD pins connection

const int Pulseinput = 2;   //pulse input pin
float EUCspeed = 0;  //speed calculated in it its float
int counter = 0;            //counter to triger step

void setup() {
  // put your setup code here, to run once:
  lcd.begin(16, 2);        //initiate lcd type
  pinMode(Pulseinput, INPUT); //input mode for the pin
  lcd.setCursor(0,0);         //set the cursor for the lcd
  lcd.print("Speed = ");      //write to the lcd
  lcd.setCursor(0,9);         //set the cursor for the lcd
  lcd.print(EUCspeed);        //initiate the speed will be 0 meter
  Serial.begin(9600);

}

void loop() {
  // put your main code here, to run repeatedly:
  while(digitalRead(Pulseinput)!= 0)  //if there is pulses will count them
  {
    counter++;
    delay(10);
    
      EUCspeed = (counter*0.018)/(10*100*60*60);
      lcd.setCursor(0,9);         //set the cursor for the lcd
      lcd.print(EUCspeed);        //initiate the speed will be 0 meter
      Serial.print("Speed = ");
      Serial.println(EUCspeed);
  }
}

Link to comment
Share on other sites

9 hours ago, Jacky Heshi said:

Here is what i go so far, but need need help with the code, the code can pick up the readings from the hall sensor, but the speed its displaying never resets back to zero

Instead of just incrementing a counter each time you read a hall sensor-pulse, you should either measure the amount of pulses within a certain time and then calculate speed based on that or keep track of how many milli- or microseconds passed between two consecutive pulses. The latter method might need some averaging over multiple samples so the reading won't jump up and down a lot.

 

Link to comment
Share on other sites

I am doing the speed calculation and it seems to work very well.

I use a counter that is incrementing at a fixed frequency (10us) and when one pulse happens, fires an interrupt. On that interrupt I save the value of the counter that is the time between pulses.

Arduino also have counters/timers and INPUT CAPTURE peripherals - you should find many examples and tutorials for Arduino :-)

Here is my code:

Code that happens on interrupt, to save the counter time and do a quick low pass filter with the readed value:

https://github.com/generic-electric-unicycle/firmware/blob/feature/speed_control/src/hall_sensor.c

/* Save current time between each hall sensor signal change */

timer = (unsigned int) TIM_GetCapture1 (TIM2);

/* Register the hall sensors time and apply a low pass filter */

hall_sensors_time = t1*0.3 + t2*0.3 + timer*0.4;

t1 = t2;

t2 = timer;

 

Code that calcs the speed, using as input the hall_sensors_time variable:

https://github.com/generic-electric-unicycle/firmware/blob/feature/speed_control/src/motor.c

/*

* speed (meters/hour) = 4032 / (138 * hall_sensor_period)

* 4032 is the meters per hour (4.032km) that one rotation per second for wheel of 14''

* 138 is the 46 magnets * 3 hall sensors

* hall_sensor_period is measured in seconds

* Examples:

* 4032 / (138 * 0.000833) = 35075 --> ~35km/h

* 4032 / (138 * 0.0059) = 35075 --> ~5km/h (the walking speed)

*

* speed (meters/hour) = 4032x10^6 / (138 * hall_sensor_period_us)

* speed (meters/hour) = 29217391.3 / hall_sensor_period_us

* speed (meters/hour) = 2921739.13 / hall_sensor_period_10us

*/

motor_speed = 2921739.13 / ((float) get_hall_sensors_10us ());

Link to comment
Share on other sites

2 hours ago, electric_vehicle_lover said:

...

I use a counter that is incrementing at a fixed frequency (10us) and when one pulse happens, fires an interrupt. On that interrupt I save the value of the counter that is the time between pulses.

...

Code that happens on interrupt, to save the counter time and do a quick low pass filter with the readed value:

...

/* Register the hall sensors time and apply a low pass filter */

hall_sensors_time = t1*0.3 + t2*0.3 + timer*0.4;

t1 = t2;

t2 = timer;

...

A filter like this should work on the values over fixed time periods? Since you have the changing periods here, you have changing filter characteristics.

I assume it won't really matter (too much) for this application - but things will get difficult if you teacher asks you to define the possible range of "error" you introduce by this method... ;)

Link to comment
Share on other sites

  • 2 years later...
On 3/9/2016 at 3:19 AM, hobby16 said:

One sensor is enough, the hall sensor output is very clean (digital, with no rebound since the hall sensor has a strong hysteresis). Two is needed only if you want to take into account... riding in reverse.

Black is ground, red is 5V (to power the hall sensors), the 3 other colors are with same coding as the 3 power wires but it's not important since you need just one.

Sorry to resurface an old thread @hobby16 or @esaj but when connecting an Arduino to the existing wheel's hall sensors should I just connect directly to the wires in parallel and 'share' the signal, and if so, do I just need the sensor pin and ground to be connected to the Arduino or should the power wire be connected to the Arduino too, and if so, to 3.3 or 5v?

I know how to write a script but I'm not great with electricity! Appreciate your help here with noob questions to get me up and running without damaging my wheel :)

Thanks

Roo

Link to comment
Share on other sites

4 minutes ago, Roo Williams said:

Sorry to resurface an old thread @hobby16 or @esaj but when connecting an Arduino to the existing wheel's hall sensors should I just connect directly to the wires in parallel and 'share' the signal, and if so, do I just need the sensor pin and ground to be connected to the Arduino or should the power wire be connected to the Arduino too, and if so, to 3.3 or 5v?

I know how to write a script but I'm not great with electricity! Appreciate your help here with noob questions to get me up and running without damaging my wheel :)

Thanks

Roo

Wow...what do you want to achieve? Just Speed measuring?

Link to comment
Share on other sites

1 minute ago, US69 said:

Wow...what do you want to achieve? Just Speed measuring?

Yeah, which will then allow me to trigger custom LED patterns to the MSX vertical LEDs on breaking and provide a visual max-speed alarm via a laser pointer that gets switched on and off and fires a beam at the ground in front of me :)

Link to comment
Share on other sites

1 minute ago, Roo Williams said:

Yeah, which will then allow me to trigger custom LED patterns to the MSX vertical LEDs on breaking and provide a visual max-speed alarm via a laser pointer that gets switched on and off and fires a beam at the ground in front of me :)

Respect!!! :)

Unfortunatly i cant help a bit...but please Keep us all updated!

Link to comment
Share on other sites

6 hours ago, Roo Williams said:

Sorry to resurface an old thread @hobby16 or @esaj but when connecting an Arduino to the existing wheel's hall sensors should I just connect directly to the wires in parallel and 'share' the signal, and if so, do I just need the sensor pin and ground to be connected to the Arduino or should the power wire be connected to the Arduino too, and if so, to 3.3 or 5v?

I know how to write a script but I'm not great with electricity! Appreciate your help here with noob questions to get me up and running without damaging my wheel :)

Thanks

Roo

Firstly, check the voltage the wheel uses on the sensors (it's probably 5V, but better make sure). To my knowledge, the hall-sensors used in the wheel motors are the kind which output their own voltage from the output (if VCC = 5V, high = 5V, low = 0V, +-something, might not go all the way to rails), but there are other kinds that for example have an open drain/collector -output (it connects the output to ground internally, or floats it in the other state). 

For measuring the sensors, see what @hobby16 said:

On 3/9/2016 at 10:19 AM, hobby16 said:

One sensor is enough, the hall sensor output is very clean (digital, with no rebound since the hall sensor has a strong hysteresis). Two is needed only if you want to take into account... riding in reverse.

Black is ground, red is 5V (to power the hall sensors), the 3 other colors are with same coding as the 3 power wires but it's not important since you need just one.

On my Airwheel, IIRC, there are 48 pulses per revolution. On my 16" Firewheel, 56 pulses/rev.

To count them, just connect a voltmeter, power up the wheel, push it gently and see the signal alternating between 0V and 5V. Easy peasy to process with an Arduino. I even have some Attiny13 programmed to convert the pulses to one count/rev so you can connect it to a bike computer (to replace the bike computer's clumsy magnet & ILS), I will give it away, just mail me.

 

AFAIK, if the voltage is 5V, you can bring the output of the hall sensor (one is enough, although you could use 2 or all 3) in parallel to a digital input of the Arduino / ATMega328P. If it's 3.3V, check the datasheet what is the minimum voltage for the digital input pins at 5V VCC to read the state as high. If it's higher (some hall-sensors work with voltages from around 3 up to 30V), you need to level-shift it for the Arduino, maybe using something like a (logic-level) N-channel mosfet or something. Only the ground needs to be common.

Simple schematic:

tFaElBL.png

I have no idea if A1101ELHL is even the same kind of hall sensor as your wheel motor uses, but the general idea is just to bring the output of the hall-sensor directly to a digital-input pin (don't use the internal pull-up resistor). I chose D2 as an example, because it has separate interrupt, and it should be quite straightforward to write a simple interrupt handler counting the pulses and changing them to wheel revolutions and to speed.

 

Link to comment
Share on other sites

Thanks so much for the detailed reply @esaj. I actually found that when 'hijacking' a hall sensor on the whee it was fine whilst lying on its side giving me nice, clean edges but when l stood it up I got a lot of switching back and fore from noise or the motor hovering around the edge of two magnets? (my conceptual model isn't all that). That said, it might be because I didn't common the ground with the control board's ground. Being an electricity noob who's wheel is his main form of transport, I was afraid to short something so I've decided to get a separate hall sensor that I'll run from the Arduino so the entire system will run independently of the wheel (apart from the USB power source going to vin, and eventually connecting to the LEDs, but at least that's not messing with the wheel's vitals.)

I've got all the bits together, hopefully gonna find some time to work on it tomorrow. I'll report my progress! Thanks again.

 

 

Link to comment
Share on other sites

Hello, based on @esajwork, I made my own speedometer/odometer  which also control MSX leds. It's not fully finished as I still use 2 arduinos for the 2 t sks because I didn't have time yet to rebuild the speedometer board for all in one.

I made it independent and used an omnipolar hall sensor to calculate time between triggers.

 

IMG_5762.JPG

Link to comment
Share on other sites

ASD

8 hours ago, Roo Williams said:

Thanks so much for the detailed reply @esaj. I actually found that when 'hijacking' a hall sensor on the whee it was fine whilst lying on its side giving me nice, clean edges but when l stood it up I got a lot of switching back and fore from noise or the motor hovering around the edge of two magnets? (my conceptual model isn't all that). That said, it might be because I didn't common the ground with the control board's ground.

The motor is noisy (electrically), but if the noise isn't too wide amplitude, it shouldn't trigger the inputs. Running a separate ground from the sensor might help. If you're using the wheel USB to power your circuit, they already share a common ground through that (I doubt it would work very well even laying on the side if there wasn't some common ground).

 

3 hours ago, Tbx Nicolas said:

Hello, based on @esajwork, I made my own speedometer/odometer  which also control MSX leds. It's not fully finished as I still use 2 arduinos for the 2 t sks because I didn't have time yet to rebuild the speedometer board for all in one.

I made it independent and used an omnipolar hall sensor to calculate time between triggers.

Nice work! I guess you mean based on this:  

I never really finished it though :P 

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...