Hi there.
This has been probably gone through like a million times but I'd like to be certain I'm not frying anything.
I need to read PWM input, programmable 31-500Hz and duty cycle between 0-100%.
This PWM signal is "generated" in MS.
Can I just use pull up resistor on this grounding wire and read PWM with Arduino?
Can I just use pull up resistor on this grounding wire and read PWM with Arduino?
No. A PWM signal is either a logic high or a logic low. Reading this with an analogue input is going to give you exactly what you see. What are you expecting?
An Arduino analogue input reads the voltage on a pin and convert it to a value between 0 and 1023 proportional to that voltage. A PWM signal only has 2 voltages, 0V and 5V so the Arduino input will only see one or other of those voltages.
What is it that you want to read concerning the PWM input ?
Grumpy_Mike:
Oh come on. You can do better than that.
No. A PWM signal is either a logic high or a logic low. Reading this with an analogue input is going to give you exactly what you see. What are you expecting?
For example this is how PWM controlled idle valve is done, so valve duty cycle is controlled with MOSFET inside device.
Now I want to replace PWM valve with 4 wire bipolar stepper motor.
Maybe I described my question wrong.
Well spot on with that observation. What is that diagram supposed to show? It seems to show very little.
I assumed that mentioning Microsquirt in topic might interest people familiar with it.
You would wait a long time for that to happen.
Given enough information any electronic engineer worth his salt should be able to have a good go at things. But you don't seem to know what you want to measure.
Do you know what PWM actually is? Read this:- http://www.thebox.myzen.co.uk/Tutorial/PWM.html
You will see it is just a digital signal, so measuring it with an analogue input does not make any sense. As I see it you have two options:-
use a pulseIn function call on a digital pin to measure the high or low period of a pulse.
use a low pass filter to convert the PWM signal into an analogue voltage and measure that
That will measure the duty cycle. But method 2 will be interdependent of frequency. Method 1 will be highly dependent on frequency.
Grumpy_Mike:
Well spot on with that observation. What is that diagram supposed to show? It seems to show very little.
You would wait a long time for that to happen.
Given enough information any electronic engineer worth his salt should be able to have a good go at things. But you don't seem to know what you want to measure.
Do you know what PWM actually is? Read this:- http://www.thebox.myzen.co.uk/Tutorial/PWM.html
You will see it is just a digital signal, so measuring it with an analogue input does not make any sense. As I see it you have two options:-
use a pulseIn function call on a digital pin to measure the high or low period of a pulse.
use a low pass filter to convert the PWM signal into an analogue voltage and measure that
That will measure the duty cycle. But method 2 will be interdependent of frequency. Method 1 will be highly dependent on frequency.
What do you want to measure it for?
Thank you Grumpy_Mike for your kind words.
I just made mistake in how I connected Arduino.
Actually I know quite well what PWM is.
Diagram was just to show how I connected pull up resistor between Arduino and MS and was thinking if it's possible to do it like this at all.
I'll use pulseIn() and try it in digital pin, I can change freq between 31-500Hz in MS.
I'll be "converting" this PWM signal to bipolar stepper motor with Easydriver.
Diagram was just to show how I connected pull up resistor between Arduino and MS
OK but I didn't see anything that looks like a resistor to me in that diagram. There are standard symbols for a resistor.
I'll be "converting" this PWM signal to bipolar stepper motor with Easydriver.
I am not sure how you will do this, but remember there is no fixed position on a stepping motor so when using one you have to use some sort of limit switch to sense the motors position. On switch on you would typically step towards this position until you hit this position and then take it from there. This might be inconvenient depending on exactly what you are doing.
Grumpy_Mike:
OK but I didn't see anything that looks like a resistor to me in that diagram. There are standard symbols for a resistor.
I am not sure how you will do this, but remember there is no fixed position on a stepping motor so when using one you have to use some sort of limit switch to sense the motors position. On switch on you would typically step towards this position until you hit this position and then take it from there. This might be inconvenient depending on exactly what you are doing.
R1 is resistor, it's EU symbol.
When I know exact count of steps needed, I'll limit movement and positions with that, atleast that was my plan.
Robin2:
There seems to be a resistor in the first diagram.
And I think your Reply #8 was referring to the second diagram - and the OP does not seem to have responded to that.
...R
o
That second diagram is an example how to connect 2 wire PWM idle valve, but I have 4 wire bipolar stepper motor.
Yes I was referring to the second diagram of which you said:-
This is how PWM controlled idle valve is done,
It actually didn't show anything useful or comprehensible.
When I know exact count of steps needed, I'll limit movement and positions with that, at least that was my plan.
That is not the issue. The issue is knowing where that motor is pointing when you power up the system. Is so that the valve is open, is it closed, is it somewhere in between? Without some form of absolute feedback you don't know and so your code will cause the motor to move to the wrong position.
Grumpy_Mike:
Yes I was referring to the second diagram of which you said:-It actually didn't show anything useful or comprehensible.
That is not the issue. The issue is knowing where that motor is pointing when you power up the system. Is so that the valve is open, is it closed, is it somewhere in between? Without some form of absolute feepdback you don't know and so your code will cause the motor to move to the wrong position.
I got you wrong then.
With that example I wanted to show that there is no actual output.
I know if there would be 5v PWM signal I could read it.
I'm aware about this position feedback, but in stock application there is no position sensor neither.
In stock application valve has to be controlled by counting steps.
Let's say starting point valve is fully closed at 100 steps, fully open would be 100 steps and these would be hardlimits in Arduino.
At startup MS would open valve (max 100 steps) and when engine temp rises MS start closing valve until fully closed (max 100 steps).
These numbers are not accurate as I don't know how much they would be yet.
But basically MS would be only closing this valve from open state as needed and Arduino would prevent closing or opening too much.
Also I think I'd make sure somehow that if there is no signal from MS, Arduino would drive valve in closed position just in case.
jonezy:
In stock application valve has to be controlled by counting steps.
Let's say starting point valve is fully closed at 100 steps, fully open would be 100 steps and these would be hardlimits in Arduino.
It may be the case that it is safe to use the physical stop of the valve as pseudo limit switch. For example if it requires 200 steps to go from fully open to fully closed then if, at startup, you go 400 steps in the closed direction you can be sure that the valve is closed and you can treat that position as 0.
All this depends on the assumption that the motor is incapable of damaging the valve by trying to move it too far. Missing steps won't do the stepper motor any harm.
Grumpy_Mike:
What do you mean by “stock applications”?
It would be a very very poor system that had no positional sensor.
It might be very poor system, but it works on stock motorcycle.
I'm retrofitting EFI system in older motorcycle and would like to use this idle control and in a stock bike it works just the way japanese/mikuni engineers wanted.
Robin2:
It may be the case that it is safe to use the physical stop of the valve as pseudo limit switch. For example if it requires 200 steps to go from fully open to fully closed then if, at startup, you go 400 steps in the closed direction you can be sure that the valve is closed and you can treat that position as 0.
All this depends on the assumption that the motor is incapable of damaging the valve by trying to move it too far. Missing steps won't do the stepper motor any harm.
...R
This motor has threads in it's axle and there is an threaded plastic piece which moves in and out when motor is spinning.
Motor frame keeps this plastic piece not turning but makes it move in and out.
I was looking this valve closer today and actual movement needed to control idle is not much.
I was planning to attach motor to valve and measure how many steps it's really needed to fully open it.
So if I carefully put all pieces to right starting positions where valve is fully closed and measure step by step distance needed to fully open valve and use this fully open step count as reference.
There is some slack in threads so it won't explode if there is few step too much or less.
Valve body is basically just an aluminium tube with 4 holes on it's sides, other end of tube holds motor and other end is air intake and this plastic piece moves inside of tube.
Sorry, I don't have pic of it at this point.
Can I just use pull up resistor and read 0 and 1 in arduinos digital pin as MS is grounding?
Or is there some other preferred way?
Also secondary butterflies work with bipolar stepper motor too and there is no ready made solution to control them, I was hoping I could give it a try at some point.
Secondary butterflies although have position sensor.
To read more on secondary butterflies (there is lots of info not needed in here but still it makes clear what it's good for):