Spare Output Variables

This forum is for discussion of MicroSquirt (TM) from Bowling and Grippo. The MicroSquirt information site is at www.usEasyDocs.com
Forum rules
Read the manual to see if your question is answered there before posting. If you have questions about MS1/Extra or MS2/Extra or other non-B&G code configuration or tuning, please post them at http://www.msextra.com The full forum rules are here: Forum Rules, be sure to read them all regularly.
jcorsaro
MegaSquirt Newbie
Posts: 18
Joined: Fri May 07, 2004 1:09 am
Location: San Diego, CA USA

Post by jcorsaro »

el-hardo wrote:can nobody paint such a circuit, please? :(
If your going to use the LEDs as a spare output, here is the simples way to install a protection diode on the v3.0 main board with MegaSquirt II v2.33 or later software. You will need to remove the LED, install a 1N4001 diode(available anywhere electronic components are sold, even Radio Shack) as illustrated bellow. Run a wire under the board from the white stripe side (cathode) of the diode to "S12C" hole near Q11 transistors leads. Then run a wire from anode wire of the diode to one of the 4 spare out pins (holes SPR1, SPR2, SPR3 and SPR4) near the DB37 connector. The spare out pins correspond to Pins 3,4,5 and 6 on the wiring harness side of the DB37 connector. Tie the appropriate pin to one side of the relays coil terminal, then tie the other relay coil terminal to a fused and switched-with-ignition-on 12 volt source. The relays contacts can control what ever you would like (i.e. cooling fans, VTEC solenoids, transmission torque converter lockup, water injection). You can copy this circuit on all three LEDs if you would like to control three different functions. In MegaTune you can route functions to the three LEDs.
For a more robust solution for driving relays, copy the circuit that is used for the fast idle relay driver in the prototype area of the PC Board, it will take more components though. Also Bosch makes relays with an integrated protection diode, but they must be wired with the correct polarity. Hope that helps.
Jeff in San Diego
el-hardo
MegaSquirt Newbie
Posts: 15
Joined: Tue Nov 01, 2005 7:16 pm

Post by el-hardo »

Thanks, thats great!

Is S12C ground ( - ) of the board? So i can connect the cathode to any ground of the board AND vehicle, outside the board?

The 2nd sheme of the Fidle circuit is a bit confusing....i don't really understand, why to use 2 transistors :oops: . But it will be no problem to copy this.
Can i build this circuit outside the board, too, and only connect the driver pin (for example the fidle - out - Pin) to a spare, and connect this spare to my circuit outside the board?

regards Jan
jcorsaro
MegaSquirt Newbie
Posts: 18
Joined: Fri May 07, 2004 1:09 am
Location: San Diego, CA USA

Post by jcorsaro »

el-hardo wrote: Is S12C ground ( - ) of the board? So i can connect the cathode to any ground of the board AND vehicle, outside the board?
S12 and S12C are 12 volts +, and you can install the diode outside the board at the relay coil terminals them self.

The 2nd sheme of the Fidle circuit is a bit confusing....i don't really understand, why to use 2 transistors :oops: . But it will be no problem to copy this.
Can i build this circuit outside the board, too, and only connect the driver pin (for example the fidle - out - Pin) to a spare, and connect this spare to my circuit outside the board?
The v3.0 Fidle relay driver circuit is more of a "bullet proof" design, the second transistor and two extra resistor protect the drive transistor from burning up if the relay or wiring is shorted. Also the for a fly back protection diode, a zener diode is used and does not have to be tied to 12 volts +. It is possible to build a board out side the MegaSquirt box, but I don't recommend having microprocessor outputs lines coming out of the MegaSquirt box. There is potential for them to short and burn up the microprocessor (expensive MegaSquirt II daughter card)
Jeff in San Diego
el-hardo
MegaSquirt Newbie
Posts: 15
Joined: Tue Nov 01, 2005 7:16 pm

Post by el-hardo »

Ok, then the LED transistor switches ground ( - ), and 12V + is always there (on the other pin of the diode)? Then i can hook up the diode to the positive side of the diode (right in front of the resistor)?

but I don't recommend having microprocessor outputs lines coming out of the MegaSquirt box. There is potential for them to short and burn up the microprocessor (expensive MegaSquirt II daughter card)
You are right!!!!! Didn't think about this :-).
jcorsaro
MegaSquirt Newbie
Posts: 18
Joined: Fri May 07, 2004 1:09 am
Location: San Diego, CA USA

Post by jcorsaro »

el-hardo wrote:Ok, then the LED transistor switches ground ( - ), and 12V + is always there (on the other pin of the diode)? Then i can hook up the diode to the positive side of the diode (right in front of the resistor)?
I think 12 volts only at S12 and S12C holes. At the LEDs positive (anode) there is 5 volts + with a 330 ohm resistor to limit the current to the LED.
Jeff in San Diego
herkamer
MegaSquirt Newbie
Posts: 12
Joined: Tue Nov 01, 2005 8:01 pm
Location: Lakewood, Colorado

Post by herkamer »

Bringing this topic back alive with more questions

After RTFM, I see it's now possible to do what I want with the spare outputs via chaining the conditions. I think I've got it to work on the stim correctly per my values, but the binary part of the equation is a bit unclear. Also, it always shows port0 whenever I fetch the information back, no matter if I send it again and again.

My setup is as follows:
2.36 firmware
MT2.25

PA0
RPM>2000
CLT>140
Triggered value=0

PM3
port0>63 (this is part I don't fully understand)
map>50
Triggered value=1

PM5
port1>63
map>75
Triggered value=1


So as I see it, with RPM above 2k, coolant above 140 and map above 50 the Injection LED should light

Map goes above 75, the Warmup LED should light up in addtion to the Injection LED. The idea here is to engage OD over 50map, and engage the LU clutch at 75map provided temp is over 140 and RPM is over 2000. Obviously these are examples just for testing, real world will probably net different numbers.

Can someone explain this a little more in non-propellerhead detail?
Chaining Spare Port Conditions

You can use the spare port variables port0 to port6 to link the status of one spare port to another, allowing you to implement control strategies that have more than 2 conditions. The port0 to port6 status is returned as a single variable representing a 7 bit field, that has a value. For example:

32 decimal is 0100000 binary, and

45 is 32 + 8 + 4 + 1 = 0101101

The trick is that while MegaSquirt-II uses the bits (0's and 1's) to set the individual spare ports (and indicate their status to MegaTune), it returns the fiels of bits as a decimal number (sort of like the datalog engine bit field).

For example, the PA0 - Knock enable spare port is bit 6 (numbered with 0 as the right-most), so to see if it is high, we check if port0 >63.

The spare port variable (spare_port) is initially set to 0 and whenever a spare port is set or unset, the program goes thru a set_spare_port subroutine in which the status of the bits in outpc.spare_port are updated, as well as setting the pin itself. You only call set_spare_port with port n as an argument if you have selected n as a spare port. If not, then spare_port does not reflect the value of port n.

If you want a condition that triggers when bit 6 is high, you can't use port_status > 0, you have to use port_status > 2**5.

You can chain spare ports in simple cases by making the condition be whether port 5 > 2**5 - 1 = 31 (or something like that). So regardless of the values on ports 0-4, the condition would only be met or not met if the 5th bit were set or not set. (This assumes port 8 is not used. You just have to order the highest ports to be the triggers. This is not as good as being able to look at individual ports, but I think you can do some chaining.
Last edited by herkamer on Mon Sep 04, 2006 7:07 am, edited 1 time in total.
Matt

80 Mustang Notch, 2.3T EFI, V3 MS2, 2.36FW, TFI, PWM IAC

Coming soon: 69 Dart Swinger 340, A500 OD MS2...hoping for 500hp!
Mike_Robert

Post by Mike_Robert »

You wrote:
The idea here is to engage OD over 50map, and engage the LU clutch at 75map provided temp is over 140 and RPM is over 2000.

Did you mean the opposite re "over 50 MAP", etc? I think you would want to engage OD & LU at low MAP/high vac as encountered during cruise rather than the opposite.

-Mike
Mike_Robert

Post by Mike_Robert »

Mike_Robert wrote:You wrote:
The idea here is to engage OD over 50map, and engage the LU clutch at 75map provided temp is over 140 and RPM is over 2000.

Did you mean the opposite re "over 50 MAP", etc? I think you would want to engage OD & LU at low MAP/high vac as encountered during cruise rather than the opposite. I'm away from the shop at the moment but will try to replicate what you're doing (which, IMHO, is quite interesting!). Please let the group know your progress.

-Mike
herkamer
MegaSquirt Newbie
Posts: 12
Joined: Tue Nov 01, 2005 8:01 pm
Location: Lakewood, Colorado

Post by herkamer »

The numbers I'm using are purely for example and bench testing. You would be correct with below 50 and 75, just easier to bench test when it's close to baro pressure :lol: I may end up using TPS rather than MAP....real world testing in the car will be the determining factor. The idea is with low load and higher rpms to drop it into 4th gear, and even less load to lock up the converter for mileage. Basically it would only lock up while cruising. It should never see it on the street unless it's a cruising situation.
Matt

80 Mustang Notch, 2.3T EFI, V3 MS2, 2.36FW, TFI, PWM IAC

Coming soon: 69 Dart Swinger 340, A500 OD MS2...hoping for 500hp!
grippo
MegaSquirt Guru
Posts: 921
Joined: Mon Feb 16, 2004 6:55 pm

Post by grippo »

For the example you cited I believe your logic will do what you wanted in the example you cited. The ports are numbered as follows:

CPU Port SW Port
----------- ----------
PM2------------0
PM3------------1
PM4------------2
PM5------------3
PT6------------4
PT7------------5
PA0------------6

Port_status is the combined one number status in binary. More on that at the end.

Now for your case you want to use:
PA0 (port 6) for the base (most critical) condition (rpm > 2000, clt > 140). When this condition is true, then port_status > 63

PM3 (port 1) for the OD (port_status > 63, map > 50) This means port 6 is on and map > 50.

PM5 (port 3) for the LU (port_status > 63 + 2=65, map > 75) This means ports 6 and 1 are on and map > 75. Actually you could get away just > 63, as you showed, because if map > 75 it has to be > 50.


Note that the port nos asre different from what you showed. Now this should work fine to get you up to the OD and LU states, and as soon as map <= 75 you should lose LU and if <= 50 you should lose OD. If the rpm or clt drop below threshold, you will lose both OD and LU. Also note that you can't use other ports as SPARE ports for other purposes without re-evaluating this logic.

Now as far as the port_status, this is obtained by putting the 0/1 state of each port in a single 8-bit memory location going from right (port0 = bit0) to left (port 6 is bit 6 and leftmost bit 7 is always 0 since there are only 7 not 8 spare ports). So when the conditions are such that you have OD and LU, then port status in binary is: 01001010

You evaluate a binary number like this as follows:

bit7 *128 + bit6 * 64 + bit5 * 32 + bit4 * 16 + bit3* 8 + bit2 * 4 + bit1*2
+ bit0 * 1

Bit1, bit2, ... are 0 or 1 (off or on) so all you do is add up the numbers for the bits that are on. So if only bit 6 was on you get 64, hence the condition > 63. Since we are dealing with whole numbers, > 63 means 64 or higher. This would correspond to the case where map was below 50 but rpm > 2000 and clt > 140. If OD and LU are on, then you have
01001010 which adds up to 64 + 8 + 2 = 74
If only OD is on, you have 01000010 = 64 + 2 = 66.
Post Reply