BETA :) RELEASE of PWM 2 STEPPER controller

A forum for discussing the MegaSquirt related (but non-B&G) board development, assembly, installation, and testing.

Moderators: jsmcortina, muythaibxr

Post Reply
masterx81
Master MS/Extra'er
Posts: 776
Joined: Mon Oct 25, 2004 7:36 am
Location: Asti - Italy

BETA :) RELEASE of PWM 2 STEPPER controller

Post by masterx81 »

Hi to all...
This is my fisrst public alpha release of this controller, that can convert a pwm signal (from the output of msns-e) to a signal compatible with a stepper motor.

THE USE OF THIS CIRCUIT (at this stage) IT'S ONLY ADVISED TO WHO KNOW WHAT IS DOING!

Before done a good release (with instructions, pcb layout and other), i need to say how it work, as (at the time of write) it's only bench tested!
I can give support, and of sure, correct bug/problems. I also accept suggestions for made it better (or at least working! :-) ).

In the zip there is:
- main.c file. This is the c source code (compiled with HI-TECH PICC compiler). It's very well commented. If you modify this, please leave my name in :-)
- Precompiled hex file for the pic 16f628. This is preconfigured with (possible) reasonable values for gm stepper (Step Time 3.0ms, Step count 170, 100 usable steps for conversion, moving only, 5% threshold in pwm change before taking in account a stepper moviment)
- Schematic circuit... It's not that nice, but if you not understand it, probably is better that you leave this project for now...
- A ICProg Shot for configuring different default values.

If you need different values that de preconfigured, you need to modify the eeprom values before programming the pic:
- The sum of address 0000 + 0001 configure the max steps that your stepper can do.
- The address 0002 is the step time (in 0,1ms - so 30 = 3.0ms)
- The address 0003, if set to 1, configure the always on movment
- The address 0004 is the threshold
- The address 0005 is the delay (in ms) that the stepper wait before move, when you are in manual mode (smaller times allow low resolution, but fastest moviment; higher permit fine changes of the idle, but slowest minimum to maximum)
- The address 0006 is the useful steps that i take in care doing the calcs.
This is here because the pintle, also if not fully open, allow already to pass the flow. This can give at the stepper a smaller range, making it more fast. Remember that a stepper valve, compared to a PWM one, is very slow changing from fully open to fully closed (this wan an original idea of slow_hemi6)

How it work:
First of all, it EXTEND the pintle, for finding the 0 position.
Then it calculate the duty cycle of the pwm signal (with frequency from 50 to 200 hz - 100 is best imho), then moves the stepper proportionally to the duty.
DC at 100% means stepper fully open, DC 0% means stepper fully closed.
For now, it made a linear interpolation, but if necessary i can made a little table.
There are 2 buttons. This are for manual controlling the stepper moviment.
Pressing them together, the led will go on, and you are ready for manual adjustment. Up button increase idle, Down decrease idle.
Pressing the together a second time, the stepper return in auto mode.

REMEMBER THAT THIS IS ONLY AN EXPERIMENT! AND PROBABLY THERE ARE FEW BUGS (i hope not in sw... I've dedicated most of the time at the stability of the code :-) ), SO CHECK, RECHECK AND RECHECK ON MORE TIME BEFORE DONE ANYTHING!

I'M NOT RESPONSABLE OF ANY DAMAGE!

Forgot to say, the driver circuit is THE SAME AS MS2, so you can also use a UDN2916, as it's the same as the one as i used.

NEW VERSION AVAIABLE, 3 PAGE, FIRST POST!
Last edited by masterx81 on Thu Feb 22, 2007 7:45 am, edited 6 times in total.
snillet
Master MS/Extra'er
Posts: 670
Joined: Tue Dec 06, 2005 1:43 pm
Location: Kungälv, Sweden

Post by snillet »

I will follow this with great interrest.
Have a throttle body with stepper motor that i want to use with a larger plenum with 4 injectors instead of my current TBI setup. And the stepper motor has GM stamped on it so it might work fine with the above setup :D

Might wait until someone else tries it out first before i hit it though 8) , since my car is a daily driver i do not want the worst bugs to happen to me.

On the other hand idle control is not THAT much of a deal if it fails on the drive to work....
hmm.
Peugeot 309GR1990 XU9JAZ(4cyl 1.9litre) 10.8:1 CR with 60-2 VR wheel decoding ,V2.2 card, singel coil and dizzy spark ,360cc 0 280 150 431 injectors. Msns-E hi-res 10d2 and E85(Ethanol) in the gastank.
masterx81
Master MS/Extra'er
Posts: 776
Joined: Mon Oct 25, 2004 7:36 am
Location: Asti - Italy

Post by masterx81 »

I repeat that is in alpha stage, so i need some tests for find (if present) any hw/sw bug.
Who want to experiment this need at least to know how to program a pic (also have a programmer), and have base knowledge of electronics...
And a car to experiment...

Forgot to say, probably in the c file there is some comment out of date, if someone have any doubt, ask me!
---COMMENTS NOW MUST BE SORTED---
Joethemechanic
Experienced MS/Extra'er
Posts: 160
Joined: Sun May 09, 2004 2:51 pm

Post by Joethemechanic »

Masterx81

THANKYOU!!!!!!!!!!!!!!!!!!!!!
I have been wanting for three years now for someone to implement IAC controll for MS1.

I think MS&Se is simply awesome, I love the fact that a $9 chip can do so much.

I know MSII runs faster and jumps higher, but the $82 price tag sucks.

I hope development will continue for the HC908, there is just something about saying " yea, I built it for $130.00, how much did you pay for that MOTEC ???? "

I know this is in alpha stage, but the genius is it relys on the PWM code for operation, so if it works the IAC idle control will be far more advanced than MSII.

I also like the manual control bottons.

Again, thanks Joe
masterx81
Master MS/Extra'er
Posts: 776
Joined: Mon Oct 25, 2004 7:36 am
Location: Asti - Italy

Post by masterx81 »

Joethemechanic wrote:Masterx81

THANKYOU!!!!!!!!!!!!!!!!!!!!!
I have been wanting for three years now for someone to implement IAC controll for MS1.

I think MS&Se is simply awesome, I love the fact that a $9 chip can do so much.

I know MSII runs faster and jumps higher, but the $82 price tag sucks.

I hope development will continue for the HC908, there is just something about saying " yea, I built it for $130.00, how much did you pay for that MOTEC ???? "

I know this is in alpha stage, but the genius is it relys on the PWM code for operation, so if it works the IAC idle control will be far more advanced than MSII.

I also like the manual control bottons.

Again, thanks Joe
I think like you...
Ms2 isn't that cheap, but it's the natural evolution of thing...
Ms1 is at it's limit, but with some optimizations (like the one that Boost Jukie is mading), removing some feature that not all uses (Traction control?) and removing some minor bugs, i think that the Ms1 can go a little over, waiting that the MS2/Extra (Thanks James!) is at a good stage.
Surely the ms2 has not all the outputs that the ms1 have...

Are you planning to test the circuit?
Joethemechanic
Experienced MS/Extra'er
Posts: 160
Joined: Sun May 09, 2004 2:51 pm

Post by Joethemechanic »

Are you planning to test the circuit?
It looks like it would be fun :? :?:

I downloaded the zip, just had time to skim over it, as I understand it I would need to get a PIC controller and programmer?
89 accord 2.0L MS1 2.98 code v2.2 board, then MS1 and Megaspark, then MS&Se.
98 accord 2.3L MS&Se, v3.0 DIS.
99 Prelude soon to be MS&Se'd, turbo'd etc.
72 ElComino 406 sbc MSII v3.0 TBI
92 F250 MSI v2.2 MS&Se
92 twin turbo stealth MS&Se v3
masterx81
Master MS/Extra'er
Posts: 776
Joined: Mon Oct 25, 2004 7:36 am
Location: Asti - Italy

Post by masterx81 »

Joethemechanic wrote:
Are you planning to test the circuit?
It looks like it would be fun :? :?:

I downloaded the zip, just had time to skim over it, as I understand it I would need to get a PIC controller and programmer?
Yes, you need the l6219 (or the udn2916 - both in dip package), the pic 16f628 (i think that the code works also in the 16f628a - you can get a sample from www.microchip.com) and a programmer (there are some simple serial programmers on the net - JDM for example).

After this, only solder -)
masterx81
Master MS/Extra'er
Posts: 776
Joined: Mon Oct 25, 2004 7:36 am
Location: Asti - Italy

Post by masterx81 »

Someone is trying this?

If it work, i think that i add thing like 'acceleration steps' and 15 min 'always on' (for problematic iac valves)...

Any comment on the code / hardware?
DaveW
Experienced MS/Extra'er
Posts: 151
Joined: Mon May 17, 2004 9:05 am
Location: North Yorkshire, UK
Contact:

Post by DaveW »

I was just thinking the other day, wouldn't it be cool to use a logic pwm output from a MS1 to drive an external bipolar stepper motor driver. This looks like just the thing I need.

I have a Picstart Plus programmer sat on the shelf from around 2000 when I was last involved in a PIC project using 16Cxx PICs. I also have an engine I'm working with for a long term project that has a GM bipolar stepper idle control.

I'll give your circuit and code a try in the next few weeks and let you know how I get on with it.
masterx81
Master MS/Extra'er
Posts: 776
Joined: Mon Oct 25, 2004 7:36 am
Location: Asti - Italy

Post by masterx81 »

Thanks!
I regret the fact that i can't test it on the road, but at the moment i can't leave the car off-use for install megasquirt.
I hope that in the next few weeks (on saturday afternoon) i can start to make an adaptor for my standard loom (i prefer leave the ability of use the standard ecu). Probably in the first period i leave my ecu to control spark & idle, while i play with fuel & ms (this is my very first aftermarket ecu install!).
I've already in mind some enhancement to the code (now it stop the execution every 0,1ms for sampling the pwm, but a better way is to interrupt the flow only every state change of the input pin, and leave an hardware counter to sample the on and off times...) but if it work, why touch it?
:-)

---EDIT---

Have a bit of spare time...
Applied the mods. Now the pwm is acquired with a resolution of 1uS, the min freq is near 15hz and max freq is (probably) hundreds of khz...
Applied also the 15minute iac. Accel step is a little more complicated (it's really needed?)...
Reduced the max steps in the 255 range (someone need more?)
All hardware timers are gone...
This evening i'll test it on the bench... Really hope that the whole project work! I don't like the idea of 'wasted time' - but at least i've learned a lot of this mcu!
masterx81
Master MS/Extra'er
Posts: 776
Joined: Mon Oct 25, 2004 7:36 am
Location: Asti - Italy

Post by masterx81 »

New release version: 1.1

This version must be more accurate.
For calculating DC (always integer from 0 to 100 - no decimal places - useless!) uses 16 bit values. I've noticed some imprevements on the moviments on bench testing... 1uS precision.
Also added 15minute iac...
The 1 ms irq is more precise (actually is 1.001uS). The stepper moving interrupt (like the previous release) is 96uS instead of 100... On 3ms calculations there is an error of 120uS. Not think that is a problem. Haven't find a valid solution...


CHANGED PIN POSITION

Pin | Old version | New version
----------------------------------------------
PWM-IN | PIN 6 (RB0) | PIN 9 (RB3)
IACDIS | PIN 7 (RB1) | PIN 6 (RB0)
PH1 | PIN 8 (RB2) | PIN 7 (RB1)
PH2 | PIN 9 (RB3) | PIN 8 (RB2)


Also the eprom mappings are changed:
- The address 0000 configure the max steps that your stepper can do.
- The address 0001 is the step time (in 0,1ms - so 30 = 3.0ms)
- The address 0002, if set to 1, configure the always on movment, 2 is 15min IAC
- The address 0003 is the threshold
- The address 0004 is the delay (in ms) that the stepper wait before move, when you are in manual mode (smaller times allow low resolution, but fastest moviment; higher permit fine changes of the idle, but slowest minimum to maximum)
- The address 0005 is the useful steps that i take in care doing the calcs.

I removed the ability to use stepper with more that 255 steps... Is this really necessary?

Hope that this is the final version...

In the zip file there is the hex file and the c source file...

Always accepting suggestions & waiting feedbacks...

NEW VERSION AVAIABLE, 5 PAGE, FIRST POST!
Last edited by masterx81 on Tue Jul 18, 2006 4:38 pm, edited 1 time in total.
masterx81
Master MS/Extra'er
Posts: 776
Joined: Mon Oct 25, 2004 7:36 am
Location: Asti - Italy

Post by masterx81 »

No one triyed this?
LucasSchneider
Helpful MS/Extra'er
Posts: 69
Joined: Thu Jan 13, 2005 4:42 am
Location: Ivoti/RS/Brsil

Post by LucasSchneider »

it's working fine???
masterx81
Master MS/Extra'er
Posts: 776
Joined: Mon Oct 25, 2004 7:36 am
Location: Asti - Italy

Post by masterx81 »

On the bench yes :)

On the real life?
71jeep
Experienced MS/Extra'er
Posts: 207
Joined: Sun Mar 27, 2005 3:57 pm
Location: Eastern Pennsylvania

Post by 71jeep »

I want to try it but I dont know much about electronics or how to implement this.
Are you using the PWM settings in MSNS-E to make this work.
Sorry if it is a dumb question.
Not being very good with electronics or not really having a understanding of electronics could I try to build the circut and implement it or just wait till it is documented a bit better?

Thanks 71jeep :P
masterx81
Master MS/Extra'er
Posts: 776
Joined: Mon Oct 25, 2004 7:36 am
Location: Asti - Italy

Post by masterx81 »

I not say if in the real car work....
But i can made a little pcb to made things easier...

Yes, it catch the the pwm duty cycle from the msns-e and convert it to a stepper motor moviment...
For automatic control, this is the only input that the circuit need.
Also the buttons are optionals (the circuit will work also without them)...

If this evening i've some time, i start to made a little sigle sided pcb.
boost junkie
Master MS/Extra'er
Posts: 802
Joined: Tue May 11, 2004 8:58 am
Location: dallas texas usa
Contact:

Post by boost junkie »

I'll be testing this once I get my car back on the road. I'd like to have 4-wire stepper control. Great work!
masterx81
Master MS/Extra'er
Posts: 776
Joined: Mon Oct 25, 2004 7:36 am
Location: Asti - Italy

Post by masterx81 »

Hi!
I've seen that someone have moved the post...
Thanks, this is the right section :-p

Today i've done the circuit layout...
Made the things easier to try this adapter...
Now i go to start to install ms in my car :-)
Boost junkie, thanks to you for the nice work on the msns-e hi res!!!

If there is some questions about the circuit, ASK! :-)

---

Whops, resolution too low... Sorry!
As first i've some time, i'll upload a more detailed circuits...

FIXED!

NEW VERSION AVAIABLE, 5 PAGE, FIRST POST!
Last edited by masterx81 on Tue Jul 18, 2006 4:39 pm, edited 1 time in total.
DaveW
Experienced MS/Extra'er
Posts: 151
Joined: Mon May 17, 2004 9:05 am
Location: North Yorkshire, UK
Contact:

Post by DaveW »

I've prototyped the circuit and tried it today. I used the schematic included in the first download, suitably adjusted with the new i/o connections.

On the original schematic you have pins 20 and 21 on the L6219 reversed, might be worth noting that, in case anyone else is using the original schematic and wondering why their stepper motor sits there and rattles !

With that minor change I have now got it working in "manual" mode on my Land Rover "hotwire" system which uses a Bosch IAC. I'll put it on the Corvette LS1 later this week in auto and see what happens :-)

The Max Usable steps value must be below 127 or the init routine gets confused. I've not investigated this fully but I suspect it's because MaxUsefulSteps is defined as an unsigned char and passed to LinearInterpolate as an int. So anything over 127 is passed as a negative number. Setting the value to 120 has fixed it and, to be honest, I'm not convinced yet that it needs more than that anyway. Maybe just change the note in the code :-)

After playing with it I think there are a couple of refinements that can be added quite easily...

1) A load input - when this goes high (tied high normally, externally kept low) the stepper steps in xx steps, temporarily increasing the revs for 2 seconds after which time control is returned to the PWM input. This can then be triggered on auto transmissions (tied into start inhibit) and for air con compressors activating. Triggered on the low to high transition. (On the Lucas Hotwire EFi ISTR it does this on any transition).

2) A solenoid IAC emulator - for users of MS without PWM control, an input that, when high, moves the stepper motor to MaxUsableSteps to give cold fast idle, when low moves to a code defined position to give warm idle.

Excellent job though, looks the business !
masterx81
Master MS/Extra'er
Posts: 776
Joined: Mon Oct 25, 2004 7:36 am
Location: Asti - Italy

Post by masterx81 »

DaveW wrote:I've prototyped the circuit and tried it today. I used the schematic included in the first download, suitably adjusted with the new i/o connections.

On the original schematic you have pins 20 and 21 on the L6219 reversed, might be worth noting that, in case anyone else is using the original schematic and wondering why their stepper motor sits there and rattles !
Oh, d***... Sorry :-)
The second schamatic seem ok. It's the case that i remove the first download and done a unique package with all corrected? (And probably pass it in beta :-) )

Now it's working in your car in congiunction with MS?
How it work? The stepper is too slow compared to the solenoid? Causes oscillations?
DaveW wrote: With that minor change I have now got it working in "manual" mode on my Land Rover "hotwire" system which uses a Bosch IAC. I'll put it on the Corvette LS1 later this week in auto and see what happens :-)
What changes you speak about?
DaveW wrote: The Max Usable steps value must be below 127 or the init routine gets confused. I've not investigated this fully but I suspect it's because MaxUsefulSteps is defined as an unsigned char and passed to LinearInterpolate as an int. So anything over 127 is passed as a negative number. Setting the value to 120 has fixed it and, to be honest, I'm not convinced yet that it needs more than that anyway. Maybe just change the note in the code :-)
What software revision have you tryied? In 1.1 it's must sorted...
I will investigate about this..
In any case, try the 1.1 code... Has some improvements..

DaveW wrote: After playing with it I think there are a couple of refinements that can be added quite easily...

1) A load input - when this goes high (tied high normally, externally kept low) the stepper steps in xx steps, temporarily increasing the revs for 2 seconds after which time control is returned to the PWM input. This can then be triggered on auto transmissions (tied into start inhibit) and for air con compressors activating. Triggered on the low to high transition. (On the Lucas Hotwire EFi ISTR it does this on any transition).
If this is useful, can be fairly easy applied...
DaveW wrote: 2) A solenoid IAC emulator - for users of MS without PWM control, an input that, when high, moves the stepper motor to MaxUsableSteps to give cold fast idle, when low moves to a code defined position to give warm idle.

Also this can be applied... The circuit board bust be revisited...
DaveW wrote: Excellent job though, looks the business !
Thanks! :-)
Post Reply