Shop OBEX P1 Docs P2 Docs Learn Events
Prop on Order need tips on 5v logic — Parallax Forums

Prop on Order need tips on 5v logic

jbalatjbalat Posts: 96
edited 2010-01-08 04:27 in Propeller 1
I will be trying to read a 5V square pulse 25Hz to 300Hz from the cars air sensor..
--> I understand I can hook that up with a 1K resistor in series and propellor should be ok ?

Then I need to send a modified signal to the ECU.. Not quite sure whether 3.6v from the propellor would work with the ecu ?


Because the input signal is always changing in frequency the pulses to the ECU need to transition very smoothly

Can someone help with a few lines of Spin code for this ?

Thanks
JB
«1

Comments

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2009-11-19 23:05
    At such low frequencies you can use a much higher value as you want to minimize the fault current flowing through the substrate which also pumps up the Prop's supply rail. I would use a value of 100K myself or at least 10K. To send a signal back just go through a logic inverter (74HCT etc) that has it's rail tied to 5V. The logic gate will "transition smoothly" which I take means switches cleanly.

    No one here could possibly help you with the code though. You have not given us anything to go on except "pulses" and "send a modified signal".

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • JonnyMacJonnyMac Posts: 9,208
    edited 2009-11-19 23:10
    I use 2.2K with 5v logic to keep the current through the internal protection diode under 500uA.
  • mikedivmikediv Posts: 825
    edited 2009-11-19 23:45
    Peter not to but in but you might have answered a question I have in the same direction. I to was wondering how I would talk from the prop to 5 volt logic I know about the 1K but the inverter sounds like an awesome idea so if I understand could I do somehting like
    prop output pin 3 volts to a 74ls04 the 04 is connected to 5 volts I am sending 3 volts to the inverter input so would the output be raised to 5 volts? I understand the output would be flipped so a low input would be a high output but the question is the prop 3 volt output to 5 volt logic enough to trigger the gate?? thank you very much
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2009-11-20 00:55
    mikediv said...
    Peter not to but in but you might have answered a question I have in the same direction. I to was wondering how I would talk from the prop to 5 volt logic I know about the 1K but the inverter sounds like an awesome idea so if I understand could I do somehting like
    prop output pin 3 volts to a 74ls04 the 04 is connected to 5 volts I am sending 3 volts to the inverter input so would the output be raised to 5 volts? I understand the output would be flipped so a low input would be a high output but the question is the prop 3 volt output to 5 volt logic enough to trigger the gate?? thank you very much

    74LS and all TTL by it's very nature will not swing to the supply rail so you will never get 5V, typically it will be 3.5V. If you use 74HCT logic then you will get full output swing and 2V input switching threshold. There are gates available in standard DIP, SOIC, and even tiny SOT-23 style packages. I use single 74HCT86s in SOT-23 as I can configure these as inverters or buffers (non-inverting). If you are using common 14-pin 74HCT04s then you can simply cascade two gates to give you an non-inverted output.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • jbalatjbalat Posts: 96
    edited 2009-11-20 05:23
    I'm not too good with the electronics side but I can have a go at wiring up a 74LS04 and ask for help if I get stuck..
    An inverted signal is not going to be a problem since it is a continuous pulse of 50% duty

    Is it worth trying without the 74LS04 just in case the ECU can read the Propellor directly ?

    This is what the code looks like on a BS2 which is far too slow for this application and the PWMPal is hopeless because it retriggers when the frequency changes...

    Main:
    PULSIN 7, 1, time 'read freq from MAF sensor
    time = time */ Scale 'allow for bs2p scale
    OnTime = time / 25 'pwm time for half wave
    OnTime = OnTime * 100 / mFactor 'Reduce freq by factor eg. 90 (%)

    IF Ontime <> prevTime THEN 'Output new pulse via PWMPal to ECU
    SEROUT 0, 45, [noparse][[/noparse]"!PWMM1", OnTime.BYTE0, OnTime.BYTE1, OnTime.BYTE0, OnTime.BYTE1]
    prevTime = Ontime
    ENDIF

    GOTO Main

    Post Edited (jbalat) : 11/20/2009 5:32:02 AM GMT
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2009-11-20 06:12
    READ MY POST

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • jbalatjbalat Posts: 96
    edited 2009-11-20 12:24
    Sorry Peter.. This is way out of my league..
    74HCT's are a little hard to come by around here (Australia)

    Jaycar and Dick Smith are the main 2 stores.

    This is the closest I could find...
    7404 TTL Hex Inverter
    But there are more choices if I search for 74HC

    assuming this one is ok then how do I wire up 14 legs ?

    Post Edited (jbalat) : 11/20/2009 12:33:58 PM GMT
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2009-11-20 13:20
    On page 43 of this·PDF·(see Fig. 45) you will find the recommended circuit for interfacing 3V circuits to 5V circuits.· I really think that the "wizards of smart" over at Philips are onto something with this, but maybe they're shills for the blinkard, nefarious component manufacturers' cabal (a bunch of real nogoodniks who just want to make things "hard" for people who want to do stuff.)
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2009-11-20 14:06
    jbalat said...
    Sorry Peter.. This is way out of my league..
    74HCT's are a little hard to come by around here (Australia)

    Jaycar and Dick Smith are the main 2 stores.

    This is the closest I could find...
    7404 TTL Hex Inverter


    But there are more choices if I search for 74HC
    assuming this one is ok then how do I wire up 14 legs ?

    You must have 74HCT or similar, there are also other ways, but 74HC or LS is not the go. I'm in Brisbane and I have never ever had problems getting any parts but if you only shop at those two places you will never have any luck. PM your address and I will send you some stuff out of my bottomless junkbox.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • train nuttrain nut Posts: 70
    edited 2009-11-20 15:19
    jbalat

    You might want to consider the CMOS cd4050 hex buffer which is used a lot to interface TTL to Higher voltage CMOS circuits.· The output swing is determined by the pin 1 voltage. The input can be voltages other than this. see attached pdf.



    ben
  • jbalatjbalat Posts: 96
    edited 2009-11-22 06:31
    PJ Allen said...
    On page 43 of this PDF (see Fig. 45) you will find the recommended circuit for interfacing 3V circuits to 5V circuits
    PJ.. Does that diagram also come in english ? I am just a newbie with this stuff ?
    Peter said...
    I'm in Brisbane and I have never ever had problems getting any parts
    Peter... Which stores do you recommend, I am in Melbourne ?
    Ben said...
    You might want to consider the CMOS cd4050 hex buffer
    Ben.. Have you used the cd4050 for this yourself Looks like this is available from Jaycar
    www.jaycar.com.au/productView.asp?ID=ZC4050&keywords=4050&form=KEYWORD


    Any ideas with the coding from stamp to spin ?


    P.S. I really appreciate everyones help
    Thanks,
    John B

    Post Edited (jbalat) : 11/22/2009 6:36:35 AM GMT
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2009-11-22 06:49
    Re "Peter... Which stores do you recommend, I am in Melbourne ?"

    You could try Rockby. www.rockby.com.au/myindex.cfm and index www.rockby.com.au/Mainindex.cfm Looks like they have a range of HCT you could use (not the HCT04 strangely though), but you can use HCT32s and join the two inputs together, or 240s or 245 or even octal latches configured as buffers.

    I'm in Adelaide and would buy about half my parts from Rockby and the other half from Futurlec. (Futurlec are a bit cheaper but can take up to a month to arrive). Hmm - I haven't been into a dick smith or jaycar for ages. Once upon a time when there was a new chip that is where you would go. These stores ought to be selling the Propeller!

    FWIW I'm using HC 373s (not HCT) to go from a prop to 5V to drive a 5V LCD display and it is working fine.

    4050 is another option. In fact there are many options and they all will work fine. Even a single transistor and two resistors if you are stuck for space. Sometimes it depends on what comes out of the junkbox first.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.smarthome.viviti.com/build

    Post Edited (Dr_Acula) : 11/22/2009 6:59:34 AM GMT
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2009-11-22 15:32
    jbalat queried...
    PJ.. Does that diagram also come in english ? I am just a newbie with this stuff ?
    English?· Whatever for?· (Hope you're not the only guy who can make a joke around here.)

    The advantage·of "my" suggestion·is its preservation of I/O bi-directionality.· Is that of value?· I could get on a soapbox and evangelise, but I won't.

    I've attached a schematic, which is the same as the PDF's, but it includes some resistor values.· I've tested this using BS170, 2N7000, VN2222L.

    If you want nothing more than to interface a device's 0/5V output to a Prop pin input then why not just use a voltage divider, two resistors or a pot, to scale it down?··It doesn't·get any simpler than that, no active devices required.· (See attachment same.)
    267 x 133 - 6K
    445 x 171 - 8K
  • jbalatjbalat Posts: 96
    edited 2009-11-24 01:04
    PJ,
    in relation to I/O bi-directionality..
    My ECU supplies 5V down the line to the sensor.. Somehow the sensor pulses this 5V

    In my application I would need to cut the wire from the ECU to the sensor and supply 5V to the sensor so it can pulse it. Then read the sensor pulse on the same wire. Then send a modified pulse back to the ECU

    Sounds like this is the better circuit to use ?


    As for the code (see earlier post).. I have downloaded a BS2 "Object" for the propeller which is supposed to let you use the pulsin and pulsout commands.. Is this slower than native spin ? How can I get the pulsin and pulsouts working on seperate cogs so that I dont have any glitches in my output ?

    Post Edited (jbalat) : 11/24/2009 3:37:49 AM GMT
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2009-11-24 23:05
    jbalat,

    Post a link to your ECU, I'm sure everybody'd love to see it.

    As for the PULSIN/PULSOUT query, perhaps start a new Subject all about that.
  • jbalatjbalat Posts: 96
    edited 2009-11-25 03:52
    Ecu Pics here but it doesnt really tell you much... More pic's here

    And some attachments from the Basic Stamp forum...
    attachment.php?attachmentid=62884
    attachment.php?attachmentid=62994

    BTW my Propeller is here.. I will do the hello world thing shortly..
    So what components do I need to order plzzzz ???

    Post Edited (jbalat) : 11/25/2009 11:57:10 AM GMT
  • jbalatjbalat Posts: 96
    edited 2009-11-26 01:00
    So question is do I order the bits that PJ recommended considering I need to deal with 5V in both directions simultaneously ?
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2009-11-26 14:29
    I'm sorry, I haven't been ignoring your post, but you've presented quite a jumble there (no offense.)
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2009-11-26 16:30
    From what I can tell/guess from your diagrams the terminal of your sensor that is marked by a red dot has a transistor which switches that terminal to ground, in the diagram below it a pull up resistor has been added which pulls this point to 5v. So when the transistor is turned on the pin is at 0V and when turned off it is pulled high to 5V by the resistor.

    So instead of pulling it high to 5v pull it high to 3.3v with the resistor, you instantly have a 3.3v pulse train coming in to the propeller.

    It then looks like you need to reduce the frequency and send it to the ECU, you could do this with a buffer/inverter chip as suggested or you could use a transistor and a pull up resistor, this time pulled up to 5v. You also want a resistor to the base of the transistor.

    I can't see where any lines needs to be able to work in both directions but as I said I am guessing a little here.

    Graham
  • jbalatjbalat Posts: 96
    edited 2009-11-26 22:48
    Thanks Graham and PJ.. Sorry for the jumble.. Electronics is not my strong point.

    I have just posted what I observe

    - There is only one wire.
    - The ECU sends 5V down this wire to power the sensor
    - The sensor switches it on and off
    - the ecu interprets the on/off pulse

    If I cut the wire to intercept the signal from the sensor then I still need to feed it the 5V otherwise it wont work..

    - So effectively the same wire from the propeller will be sending 5V and receiving the sensor pulse to calculate the frequency
    - The output wire from the propeller will be getting the 5V from the ecu but it will be generating a new 3.3v pulse back

    Does this make sense ?
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2009-11-27 01:07
    jbalat,

    You have misunderstood what is happening in the circuit and I did not notice the internal pull up in the ECU.

    Pin three of the airflow sensor can do only one thing, it can switch a transistor on pulling that pin down to ground. This is called an open collector output, please look that up. The original ECU connects this pin to 5v (shown as a circle with a line through) via an internal pull up resistor and to the rest of its circuit via another resistor (shown by a wiggly line).

    BUT it is not a question of it "providing the pin with 5v" it is just creating a simple circuit of transistor and pull up resistor. When the transistor is on the pin is pulled down to ground by the transistor, when it is off the pin is pulled up to 5v by the transistor in the ECU.

    BUT the modified version with the wire cut shows the sensor pin pulled up to 5v via an external resistor. BUT this could just as easily be pulled up to 3.3v which would make the output of the sensor compatible with the propeller.

    Once you have modified this signal in the propeller you need to send it to the ECU, to do this you just need to emulate the output circuit of the sensor, that just needs a single transistor. The base connected to propeller pin via a resistor, the emitter to ground and the collector to the pin of the ECU.

    Please do read what I have written carefully, it means you only need two resistors and a transistor and you are cooking with gas.

    Graham
  • jbalatjbalat Posts: 96
    edited 2009-11-27 05:45
    Graham I really appreciate your input and I promise to read and understand everything you have written.
    If you could mention a transistor and resistor value then I can order some bits

    Just a note though that when I cut the wire the ECU came back with 3 error codes and not 1.. ie. MAF sensor, IAT sensor and Atmospheric sensor.. Could this wire also be feeding the other 2 sensors with the 5 volts from the ECU ?

    Just let me know if you think I am on Drugs [noparse];)[/noparse]
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2009-11-27 09:34
    First to answer your question: "Could this wire also be feeding the other 2 sensors with the 5 volts from the ECU"

    Not according to your diagram, you have a confused notion that you can supply 5v and get a signal back down the same line, look at the circuit it shows, the output is just a transistor. If it were a supply how would the signal be sent down it? If the pin pulses then it goes low high low so on every low power would be lost.

    I have no idea about the other error codes but the diagram of the sensor and the ECU plus the way in which the other guy wired his stamp up suggests I am correct, the little diagram at the bottom even shows how the air sensor is acting like a switch to ground.

    I have attached a little diagram to explain what I mean more clearly, the propeller chip is just diagrammatic, it takes in the air sensor signal at one side and outputs the modified version at the other.

    The choice of transistor is not critical but the base resistor will depend on the transistor, I can't remember the last time I bought a transistor (the last time I used one it was a kludge with a BFY51) so I'm hoping others have some suggestions.

    Graham

    attachment.php?attachmentid=65395
    1378 x 503 - 45K
  • jbalatjbalat Posts: 96
    edited 2009-11-27 09:57
    Graham you are legendary..

    I hope you have not based too much on the Stamp Setup. That was my circuit I tried to use prior to purchasing the Propeller including the picture below it with the switch. It would work at certain revs but on the whole the car was not driveable.. The car would jump around like crazy but it did not register an engine fault.

    I assumed it failed because the stamp was too slow and the PWMPal was retriggering therefore sending the ECU a screwy signal everytime the input changed

    Hopefully someone can help with resistor values for your circuit above

    Many thanks !!!!!! [noparse]:)[/noparse]

    Post Edited (jbalat) : 11/27/2009 10:03:26 AM GMT
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2009-11-27 12:16
    Well I think your stamp circuit is right even if I am mystified how you came up with it [noparse]:)[/noparse]

    Rather than waiting you could look at this:

    www.kpsec.freeuk.com/trancirc.htm

    The section on "Choosing a suitable NPN transistor" is ideal. You can even measure the current that the transistor will be switching by connecting an ammeter from the ECU pin to gnd.

    Cheers,

    Graham
  • jbalatjbalat Posts: 96
    edited 2009-12-09 12:40
    Just wired up the board with Pot, button, led, 9v regulator, etc.. Everything except for the input and output signals.

    So on the Air sensor side we are basically working off 3.3v (VDD) via the 10k ?

    On the ECU side...
    From the link you gave me I calculated a resistor of about 660 ohms (I have 1K) using a supply voltage of 5V and a load current of 4ma (measured when I cut the ECU/MAF wire).
    This gave a hFe(min) of around 4. Looking at the transistors page looks like anyone of them will do ?
    So I will probably use a BC107 since I think I have one somewhere..

    P.S. If you know anyone that wants to buy my stamp then pls let them know. ebay item 150394792459

    Post Edited (jbalat) : 12/9/2009 12:50:02 PM GMT
  • jbalatjbalat Posts: 96
    edited 2009-12-13 22:34
    Graham the diagram did not work ?

    I dont think the 3.3V on the Airflow sensor side was enough to get a signal back..
    Subsequently there was no output from the transistor..(I used a BC337 with 1KOhm resistor)

    I am going to try hooking up the Propeller similar to the stamp

    5V to airflow meter running in parallel via 10K going to the input pin on the propeller

    On the ECU/propeller output pin just connect directly via 2K resistor ?

    Post Edited (jbalat) : 12/13/2009 10:42:06 PM GMT
  • jbalatjbalat Posts: 96
    edited 2009-12-16 03:43
    I am going to try this to interface the propeller with the 5v logic on my Mitsubishi ECU.


    Anyone see any issues ?
    attachment.php?attachmentid=65899
    1024 x 396 - 38K
  • jbalatjbalat Posts: 96
    edited 2009-12-21 12:35
    Thanks to everyone that helped its all working now.

    Just a minor mod to the circuit and a modification to the code to ignore any input frequencies that go astray due to noise (only allow 20Hz to 400Hz.)

    attachment.php?attachmentid=66034

    Post Edited (jbalat) : 12/21/2009 12:42:27 PM GMT
    1024 x 396 - 37K
  • jbalatjbalat Posts: 96
    edited 2010-01-08 04:27
    This is the completed board installed in the car
    448 x 321 - 126K
    448 x 336 - 117K
Sign In or Register to comment.