University Project HELP!

Hi Guys,

A complete Arduino/Code newbie here so any help will be greatly appreciated. I study product design engineering at university and for my final year project I'm looking to integrate one of the Genuino boards into my design.

I really need some help with a circuit/code design that would allow a magnetic sensor to detect a pause in the rotation of a wheel, before triggering a back and forth motion on a servo (after a pause) so many times before the system reset. (Basically an Anti-lock braking system).

I would like to simulate the design on Autodesk 123D Circuits (Something I could simulate the board on, if possible, as I don't yet have any boards/components yet).

Any help would be great. Please keep it simple! Thanks

Tom

Not exactly sure on what you are asking.

You basically seem to want one of us to give you a complete sketch, design and requirements...or better known as "do my project for me!".

Have you used google? My first search pretty much nailed half of your issues...

Google Search "Magnet Sensor Arduino"

Johnny010: Not exactly sure on what you are asking.

You basically seem to want one of us to give you a complete sketch, design and requirements...or better known as "do my project for me!".

Have you used google? My first search pretty much nailed half of your issues...

Google Search "Magnet Sensor Arduino"

Obviously not getting across to people what I'm asking. Certainly not asking for someone to 'do my project for me'! I was actually looking for help! What I am looking for is for a experienced Arduino user to point me in the correct direction in types of code I should be looking at? How in depth and complex the code would have to be, (i.e..will a beginner be able to code such a thing) and some advice on choosing the correct board for the application etc. and yeah I've tried google.

The code will be fairly easy.

Just Google “arduino and hall effect sensor”.
And arduino and servo.

There will be many video tutorials and code snippets.

PS this could be done on a very basic arduino. I would go for an UNO to begin with for simplicity and the huge resource of tutorials and support for them.

I agree with Johnny010, pretty much any microcontroller capable of driving a servo and monitoring a Hall effect sensor would work.

Break the project into parts. Learn to use the Hall effect sensor and learn to use the servo. Once you can use the two components individually it shouldn’t be hard to combine them into your final project.

I think the Hall effect sensor will likely act a lot like a button. You’ll want to make sure you get one with the right sort of sensitivity to detect the motor. I don’t know enough about Hall effect sensors to know what part to suggest.

I just reread the original post.

tom_donaldson:
I really need some help with a circuit/code design that would allow a magnetic sensor to detect a pause in the rotation of a wheel,

The Hall effect sensor assumption may have been premature.

What sort of wheel is this? Do you have a reason you want to use a magnetic sensor? Is there a magnet on the wheel?

A Hall effect sensor may be the correct sensor to use but is it really part of the problem description? Would it be okay if you could detect the wheel stopping without using a magnetic sensor?

DuaneDegn: What sort of wheel is this? Do you have a reason you want to use a magnetic sensor? Is there a magnet on the wheel?

A Hall effect sensor may be the correct sensor to use but is it really part of the problem description? Would it be okay if you could detect the wheel stopping without using a magnetic sensor?

I assumed he had specifics on this. Brake discs with magnetic areas or something.

DuaneDegn: I agree with Johnny010, pretty much any microcontroller capable of driving a servo and monitoring a Hall effect sensor would work.

Break the project into parts. Learn to use the Hall effect sensor and learn to use the servo. Once you can use the two components individually it shouldn't be hard to combine them into your final project.

I think the Hall effect sensor will likely act a lot like a button. You'll want to make sure you get one with the right sort of sensitivity to detect the motor. I don't know enough about Hall effect sensors to know what part to suggest.

I just reread the original post.

The Hall effect sensor assumption may have been premature.

What sort of wheel is this? Do you have a reason you want to use a magnetic sensor? Is there a magnet on the wheel?

A Hall effect sensor may be the correct sensor to use but is it really part of the problem description? Would it be okay if you could detect the wheel stopping without using a magnetic sensor?

Thanks for the reply. Yeah it the hall effect sensor will detect pulses from magnets on the spoke of a rotating bike wheel. I'm wanting to be able to detect the time between signals given from the hall effect sensor, and when the wheel locks up (Skid), for the hall effect sensor to tell the arduino the wheel has locked triggering a back and forth motion on a servo 5 times or so before the system resets and waits for another sudden stop in receiving signal from the hall effect. Hope that makes sense? What i'm struggling with is how to code in "wait for gap in signal greater than 5 seconds"

Hope I'm making sense, i'm still trying to figure this all out :D

Cheers

I think if you have to wait for five seconds before deciding that the wheel has locked, you're already under the bus.

AWOL: I think if you have to wait for five seconds before deciding that the wheel has locked, you're already under the bus.

500 milliseconds rather :D :D

tom_donaldson: What i'm struggling with is how to code in "wait for gap in signal greater than 5 seconds"

I suggest no worrying about the Hall effect sensors for now. Wire up a button to use to test your code. You'll want to use two "unsigned long" sized variables to keep track of time. You'll store the times of the button presses in these variables. Use either the "millis()" micro or the "micros()" micro to record the time of the button presses.

This is pretty basic stuff. Post what you've tried (after giving it a try) and let us know what unexpected results you got. I'm sure someone could help you fix the code if it's not working.

Edit: Same applies to 500ms.

you might consider an accelerometer to differentiate between skid/lockup and an actual stop.

Ah right! I'll have a go at some code with the "Unsigned long" variable over the next few days. I haven't actually bought any boards/components yet, I've been using the Autodesk 123D Circuit simulator?

I've thought about using an accelerometer before, however it would have to be attached to the rotating wheel? Causing cable mess (I presume).

I am guessing you have not looked to much at how real life? the very basics of the system is that it compare all the wheels speeds and if under brakes one or more wheel speed is significantly different to the others it rapidly pulses the brakes on that wheel to prevent lock up. Modern ones may you an accelerometer within the system as traction and stability control systems operate a lot via the ABS system and use the same sensors for the most part.

For your system, id guess you have more than two wheels. Have not done any real arduino programming yet, am new here but do know a fair but on cars etc so might be able to help on that side

Unless you are building ant-lock brakes for a unicycle, it is the relative speed of two or more wheels that matters, not the speed of a single wheel.

SquireT: I am guessing you have not looked to much at how real life? the very basics of the system is that it compare all the wheels speeds and if under brakes one or more wheel speed is significantly different to the others it rapidly pulses the brakes on that wheel to prevent lock up. Modern ones may you an accelerometer within the system as traction and stability control systems operate a lot via the ABS system and use the same sensors for the most part.

For your system, id guess you have more than two wheels. Have not done any real arduino programming yet, am new here but do know a fair but on cars etc so might be able to help on that side

SquireT, thanks for the reply. As for as my thinking goes - the system will be connected to the rear brake/wheel of a bike only. When a magnetic sensor detects a lock of the rear wheel, information will be sent to the servo, and a rapid back and forth relay initiated. Once I have the arduino system set up I will look into editing the code so the relay is only initiated when a rapid deceleration and of the wheel occurs, not a gradual deceleration (Stopping the bike for a rest ect.).

Here's some timing code to help get you started.

const byte SENSOR_PIN = 2;
const byte LED_PIN = 13;
const unsigned long LOCKUP_THRESHOLD = 500;
unsigned long lastSensorTime;
const boolean ACTIVE_STATE = LOW; // change to match sensor
const boolean INACTIVE_STATE = HIGH; // change to match sensor
boolean sensorState = INACTIVE_STATE;

boolean previousSensorState;

void setup 
{
  pinMode(SENSOR_PIN, INPUT_PULLUP); // change if pull-up isn't needed
  pinMode(LED_PIN, OUTPUT);
  lastSensorTime = millis();
}

void loop
{
  previousSensorState = sensorState;
  sensorState = digitalRead(SENSOR_PIN);
  if (sensorState != previousSensorState && sensorState == ACTIVE_STATE)
  { 
    lastSensorTime = millis();
  }
  if (millis() - lastSensorTime >= LOCKUP_THRESHOLD)
  {
    lockupAction();
  }
 }

void lockupAction()
{
  digitalWrite(LED_PIN, HIGH);
  delay(LOCKUP_INDICATOR_TIME);

  // reset system to watch for next lockup
  digitalWrite(LED_PIN, LOW);
  sensorState = INACTIVE_STATE;
  lastSensorTime = millis();
}

I didn't try to compile it so I'm not sure if I have the syntax correct (I typed into the forum editor window). It's obviously untested. Hopefully it will give you an idea of how to time an interval between button presses or sensor events.

I wrote the code assuming you'd use a button to test the code. The button should connect the sensor pin to ground. The button is active low and is pulled high by the Arduino's internal pull-ups.

The "lockup" trigger a LED on pin 13 to light up. You might want to set the value of "LOCKUP_THRESHOLD" higher while testing with a button.

tom_donaldson: SquireT, thanks for the reply. As for as my thinking goes - the system will be connected to the rear brake/wheel of a bike only. When a magnetic sensor detects a lock of the rear wheel, information will be sent to the servo, and a rapid back and forth relay initiated. Once I have the arduino system set up I will look into editing the code so the relay is only initiated when a rapid deceleration and of the wheel occurs, not a gradual deceleration (Stopping the bike for a rest ect.).

You are welcome Tom, if it is a motorbike the vast majority of the braking is done by the front brake which if locks will chuck you off the bike, but the rear locking up isn't as fast to want to chuck you off.

It does sound a good project, and ABS is still quite new to the bike world overall, mind if I ask what else the project entails, as might be some other paths the overall idea could go down if it is to say increase safety etc

Hi,

When a magnetic sensor detects a lock of the rear wheel, information will be sent to the servo, and a rapid back and forth relay initiated.

Any reason for the servo to relay?
The Arduino can control a relay with a MOSFET as a driver, or are you referring to “relay” as a back and forth motion?

Tom… :slight_smile:

TomGeorge: Hi,Any reason for the servo to relay? The Arduino can control a relay with a MOSFET as a driver, or are you referring to "relay" as a back and forth motion?

Tom.... :)

Sorry for the confusion Tom, I am indeed referring to a back and forth motion from the servo. I would like to be able to adjust the timings of the back and forth motion, ruling out (I presume) a MOSFET driver.

Tom :D