Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Hall Effect Sensor Question... PWM too...

Status
Not open for further replies.

iso9001

New Member
I have this hall effect sensor that is measuring the speed of a shaft... the sensor puts out about a 1k signal when the shaft is at full speed... The hall sensor (i'm told) makes a square wave, exactly like a PWM... Now I'm going to drasticaly chage shaft sizes, but i cant modify the sensor and i need the sensor to act like the same as it did w/ the smaller shaft... So i want to make a pic deal to take the signal coming in, the adjust it to what it 'should' be then output that on a pwm

So I was planning on taking the signal coming in, sample it (count 1 high wait for 1 low, counter++), do this for a set amount of time (.125 seconds), take my counter and divide over time (pulses per second) then adjust the that value (i can do the shaft size change math) and set the PWM to a correct value...

Is that a pretty good way to go about it ? Or does anyone have anything better ?

Thanks
-Kyle
 
What is your application (ie, what is the shaft driving), and what exactly are you trying to achieve? Do you want to keep the rotational speed (rpm) the same, or the linear speed the same?

More details would be useful in assisting you.
 
iso9001 said:
I have this hall effect sensor that is measuring the speed of a shaft... the sensor puts out about a 1k signal when the shaft is at full speed... The hall sensor (i'm told) makes a square wave, exactly like a PWM... Now I'm going to drasticaly chage shaft sizes, but i cant modify the sensor and i need the sensor to act like the same as it did w/ the smaller shaft... So i want to make a pic deal to take the signal coming in, the adjust it to what it 'should' be then output that on a pwm

So I was planning on taking the signal coming in, sample it (count 1 high wait for 1 low, counter++), do this for a set amount of time (.125 seconds), take my counter and divide over time (pulses per second) then adjust the that value (i can do the shaft size change math) and set the PWM to a correct value...

Is that a pretty good way to go about it ? Or does anyone have anything better ?

Thanks
-Kyle

The signal from the sensor isn't a PWM signal, the frequency of it varies with the speed of the shaft, not actually the pulse width - obviously the pulse width changes as well, but with PWM the pulse width changes and not the frequency.

So you need to measure the frequency from the hall-effect sensors, carry out the calculations, then output the corrected frequency. Depending on what it's all used for, and how it's designed, you may not need full linear output, just a few selected frequencies may be all that is required.

As with all these sort's of questions, more info would be helpful - what does this all do?, and what does it actually feed?, is it analogue or digital?. It could be quite simple to modify what it feeds, particularly if it's an analogue speed controller.
 
More info...

The sensor reads into another processor that is sealed and cannot be modified.

But only the shaft changed, it still spins the same speed as before, but since the diameter changed the signal send back is wrong. The old processor will get a signal saying its too slow or too fast depending on which shaft i go with (smaller/larger, most likely larger)

So i have this processor getting a wrong signal, I want to divert that signal into the PIC then send out a 'corrected' signal.

Things I know are that I will need to be able to monitor and correct the full range of speeds (full linear output). The hall is 5V analog, the original processor expects it to hit a 1K resistor before it goes in, but thats no problem. I can get the coeffiecnt for shaft sizes... Thats easy.

But I dont understand the difference between wave width and freq ??? Cant the PWM change the period of the wave ? Isnt that what the Hall is doing ?

Could a send a PWM out that mimics a sampled hall effect output ?
 
Re: More info...

iso9001 said:
But only the shaft changed, it still spins the same speed as before, but since the diameter changed the signal send back is wrong. The old processor will get a signal saying its too slow or too fast depending on which shaft i go with (smaller/larger, most likely larger)

But I dont understand the difference between wave width and freq ??? Cant the PWM change the period of the wave ? Isnt that what the Hall is doing ?

If the shaft is still running at the same speed, why does that affect the output of the hall-effect sensor?. Such a sensor would normally be triggered by a magnet, or more than one magnet, on the shaft - giving a pulse for each magnet as the shaft rotates. Increasing the diameter of the shaft won't increase the number of pulses per revolution, unless you increase the number of magnets.

Frequency is the amount of time for a complete cycle, the high part and the low part - as the shaft gets faster both of these get shorter.

PWM is the width of one of the pulses, usually the high part, as this increases the lower part decreases, keeping the frequency constant. 100% would be all high, 0% all low, and 50% half high and half low.

You could set the PWM on a PIC to match the pulse width of the original, and vary it's frequency - but I'm not sure how wide a range, or what resolution you can get - the datasheet will tell you.
 
You are having problems..... yes if the shaft is larger you have problems my friend. If only one magnet is present in the shaft (which is how I am picturing it) when the shaft completes a revolution, the hall effect will generate a pulse, (probably a low pulse).

When you change the shaft to a larger one, the magnet will travel longer before reaching the hall effect, even though the shaft has the same RMPs. So what happens here? Imagine you put a shaft with a diameter twice larger than the old one. When the current controller is specting a signal from the hall effect, the attached magnet will be half revolution on the shaft.

At this point you want to have a PIC send the missing pulse that the old shaft would have generated right? But how does the PIC know if the shaft is in fact rotating at the rmp it is?

If you were to replace the old one with a smaller radios shaft then you would have more pulses generated, and the pic can do the conversion because it can tell the speed of the shaft. So if the new shaft was twice smaller than the old one then every two pulses from the hall effect, the pic will generate one pulse for the controller. Now that is easy to do....

But if you need to fill in the gap, like when it occurs when you have a bigger shaft, then you are not going to be accurate. Since you will send a signal without knowing if the shaft is even still moving. If you can live with that then, it would not be too hard to do :)

The way I would do it is:
1. set a timer on when a first pulse is found (probably thru an interrupt)
2. Read the timer value when next pulse arrives
3. Reset timer to start counting for next pulse
4. Figure out rpm
5. Create signal according to rpm
6. go to 2.

Hope it gives you some ideas

Ivancho
 
Exactly

Well, that IS the problem. Anytime you change shaft sizes, gears, pulley size its going to through speed sensors off. Ivancho did a pretty good job of explaining that.

1. set a timer on when a first pulse is found (probably thru an interrupt)
2. Read the timer value when next pulse arrives
3. Reset timer to start counting for next pulse
4. Figure out rpm
5. Create signal according to rpm
6. go to 2.

Thats exactly what I was thinking. Well... I was going to skip the interupt part and just monitor it in a fast moving code. I'm not sure if when you set an interupt, does the timer count one high and one low, or does it just reset on low, do I specify that (I've never used an Interupt), or is it going to count my high, loop through the code see high again and count one wave twice.

I know I can write my own sampling code in a minute. Not sure about interupts (still haven't done em)

What I'm wondering is can I make the pwm change freq and wave width (it seems like this where I have equal spaced teeth on my shaft I should only need a 50% Duty wave at a variable freq)
 
That is wrong. Nigel already explained this correctly. I'll take another stab at it.

If you have a shaft rotating at a given RPM, a magnet (or whatever) on the shaft will take the same amount of time to make one rotation, independent of the shaft size. Think about it - RPM - revolutions per minute. At 1RPM, it take a minute for the shaft to make one 360 degree rotation - independent of the diameter of the shaft.

Am I missing something here?
 
Ron H said:
That is wrong. Nigel already explained this correctly. I'll take another stab at it.

If you have a shaft rotating at a given RPM, a magnet (or whatever) on the shaft will take the same amount of time to make one rotation, independent of the shaft size. Think about it - RPM - revolutions per minute. At 1RPM, it take a minute for the shaft to make one 360 degree rotation - independent of the diameter of the shaft.

Am I missing something here?

I don't think so :D

I notice iso9001 has just mentioned 'equally spaced teeth', which he's not mentioned before!.

I'll repeat a summary of my previous statement (and your's).

IF THE RPM IS THE SAME, THE NUMBER OF PULSES WILL BE THE SAME, REGARDLESS OF THE DIAMETER OF THE SHAFT.

iso9001 - a question, what activates the hall-effect sensor?.

If it's 'spaced teeth', your problem is simply that you've put more spaced teeth on' - reduce the number of teeth to the same as the previous shaft. Depending how it's fitted, you could do this by making bigger teeth, or by removing teeth - if you do this evenly round the diameter it should still work as normal.
 
Sorry I should have pointed out that the sensor is read alot of teeth equally spaced on the shaft.

Teeth can not be modifed. I'm changing shafts but its more important to say I am changing the number of teeth. The sensor is 'activated' by having a ferrous gear tooth pass by it where it sends a low or high pulse back to the cpu

I say 'activated' because I'm not sure if the non-moving state of this sensor is HIGH and when a tooth passes over it, it goes low... Or its default is LOW and goes high when a tooth passes over. Its the same problem either way.

So... I figure at its peak speed w/ the shortest set of gears I'l get a max rpm of 1000 pulses/sec (so my sample rate has to be 2kHz).

I played around a bit with PWM, but I dont have an osc-scope so its pretty much pointless to me to set different values.

I'me also starting to think that the size of the high portion of the gear tooth is not equal to the size of the low gear tooth... So it seems this would be the place PWM would be perfect... If the high portion is 75% of one high and low tooth, I set the duty to 75% and the freq to a proper 'adjusted' value.

Would an Interupt count one high twice if I sampling rate was 4kHz or does it count one high and wait for a low to continue ? (My/Nyquist theory)
 
I doubt that the system cares about pulse width (within reason), it is just interested in frequency. If the number of teeth on the new shaft was double the number of teeth on the old shaft, you could just delete every other pulse.
 
It makes it hard when you don't know the exact way the measurements take place or the machine itself. I would be looking at a physical solution first. Is it possible to attach a disc with the same number of "teeth" as the original shaft on the end of the new shaft? This way you could swap shaft sizes without making adjustments as the micro controller is looking at the disc with the correct number of teeth at the end of the shaft. If the ends are accessable it should not be hard to tap a thread to hold the disc.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top