Shop OBEX P1 Docs P2 Docs Learn Events
RCTIME help. Reading 0 to 5V and need steady results. - Page 2 — Parallax Forums

RCTIME help. Reading 0 to 5V and need steady results.

2»

Comments

  • T ChapT Chap Posts: 4,223
    edited 2012-01-15 10:42
    There is no way that is going to work at that distance.

    Included in the ADC object:
    The two capacitors and the 100kΩ resistor must be placed within 1" of the Propeller for stable
    operation of the circuit and any excess leads must be cut away. This circuit will not work by
    placing it on the Demoboard's breadboard.
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-01-15 10:47
    wow. I guess that would be an issue then. Let me restart on that circuit and put it on the development board in an open area. I am glad you posted that!
  • frank freedmanfrank freedman Posts: 1,983
    edited 2012-01-15 11:24
    RCTIME does work, but in cold temps, it shows a different reading than with warm temps. It is not accurate enough for what I need.

    I just went out and tested the circuit as posted above without the TPS Vref and it is still way to jumpy. At 0% throttle, the voltage is 0.51v. At full throttle, it is 5.00V. The way I have it hooked up now, the display shows 1356 and sits there till about 1/4 throttle. When it hits that, it starts jumping from ~1800 to ~3400 while holding the throttle steady. It does the same at any position above 1/4 throttle all the way up to full throttle. It is like it is not picking up something correctly. I have checked all connections to ensure they are secure and connected to correct places. This is frustrating :p All a learning experience though! Is there a different design to the circuit that I could use the ADC with?

    I am using the 12 bit output since that should be all I need. the 8 bit is really jumpy and it would be hard to get an average.

    How much vibration is present in the system at various throttle positions? Since a pot is essentially a metal somewhat springy wiper on a resistive surface, I wonder if you are getting different readings due to what would be the equivalent of bounce? Perhaps needing to be averaged out using an RC filter with an appropriate time constant so as to average out the value. Any way to see what the ADC input signal looks like on a scope? Preferably a storage scope w/ glitch and persistence to capture transients. See if they are present and what effect the % throttle has on the signal. Maybe the automotive engineers that designed the ECM may be doing this or digitally filtering/averaging the TPS input to remove vibration effects.

    Just an idea for what it is worth.

    FF

    Just noticed the last couple of posts, you really should go to an ADC chip. Even if you had to mount the actual ADC close to the TPS or ECM, it is easier to drive the digital clk, csel and data than to get the S/D adc to work over a long distance. My reply on the other thread recommended opamp to scale input to 0-5V range with 12 bit ADC chip. Better reliability, less headache with sensitivities of S/D adc.

    As to an optical encoder, possible if you can get attachment to the shaft, but these are not cheap. I run across these primarily in User Interfaces on Ultrasound systems, and replacement from digikey etc. run from USD 50.00 256 pulse/rev to north of USD 600.00 3600 pulse/rev
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-01-15 12:01
    I don't have an O-scope yet since I can't afford one :( I am doing good ordering anything extra parts right now to get this working. I was hoping to stay away from having to order ADC chips since I really cannot afford to purchase anything else at the moment. I had it working once before with RCTIME which seemed to be ok, but I can't get the accuracy correct. It consisted of maybe $0.10 in parts which were 2 resistors and a ceramic cap. The problem I had may have been due to the distance away from the chip as well. It was also running on the breadboard 1ft away.

    It does not have to be 100% accurate, but it at least needs to give results back of 0 to 100%. RCTIME was always steady and not jumping around everywhere like the ADC function. It just changed 1 to 3 numbers based on how long the circuit was on or how cold it was. If I get it closer to the chip, will it be accurate to +/- 1?
  • T ChapT Chap Posts: 4,223
    edited 2012-01-15 12:41
    What kind of resolution do you need? If you divided the distance of travel of the throttle by some number of divisions, what is the least amount of divisions you could live with? If for example you could get by with 10 steps, then you could use 5 LM393 comparators, set the ref voltage to each one with 2 resistors(voltage divider), then the throttle can trip each comparator as the voltage gets larger. The Prop could read the 10 comparator outputs and determine which was the highest.

    I have done another trick instead of using the Props ADC or external ADC that will also give a high resolution measuring a voltage.. This requires one part of a comparator( I use a 393). It also requires just a few caps and resistors.

    The idea is, to use the Prop to create a voltage (DAC). I simply use a counter, set a frequency and output a psuedo PWM to create the DAC. Feed the Prop output voltage to one input of the comparator. Then feed the other input of the comp with the throttle(restrict to 3v3). Next, you 'sweep' the output voltage from the Prop to the comp input starting at 0v and rising to 3v3, incrementing the voltage at whatever resolution you want. At each increment(increase in frequency to raise the voltage output), check the comparator output. If it has tripped, then you have exceeded the throttle and know very accurately what the voltage is. This idea is more forgiving on a breadboard than using a ADC method.

    Here is the code I use to set the iTrip value:
    PUB iTRipSet  
         Dira[CurrentTripSetPin] := 1
         outa[CurrentTripSetPin] := 0
         ctrb := %00100 << 26 +  CurrentTripSetPin   'dac output
         frqb := 3000
    
         repeat
           phsb := TripLevel      ' this is set on the fly somewhere else.  
    
    
  • T ChapT Chap Posts: 4,223
    edited 2012-01-15 12:57
    Actually if you could get by with low res, you could set up 10 voltage dividers and feed it to 10 inputs. Above a certain voltage the prop will consider it a 1. A fancier way could include a matrix and get higher res, 4, 8 bits with just a few resistors.
  • pedwardpedward Posts: 1,642
    edited 2012-01-15 13:54
    Tim, it's been a while since I researched all of the EFI systems out there, but I designed a functional piggyback datalogger for OEM EFI systems. Your car is a Mitsubishi and I would be you have Nippon Denso components in the car. The TPS is a potentiometer, 1 wire to ground, 1 output to the ECU, and 1 to the +5v supply of the ECU.

    First, you are very likely picking up interference from your ignition system, you need to wire up a connection to remove the Prop board from the area. You need a 2 wire shielded cable (they sell rolls at Radio Shack last I checked). Connect the TPS output and +5v to the inner wires, then connect the shield only to the Prop ground. You must also power the circuit from the car, so the car and the Prop are at the same ground potential.

    You MUST only ground the shield at on end.

    Second, the AN008 is specific in that you MUST put the components for the Sigma-Delta ADC very near the prop chip, otherwise you may get undesired results.

    Sigma-Delta is the cheapest way to get ADC on the prop, but the MCP3202 is also a good choice.

    YOU HAVE TO USE A VOLTAGE DIVIDER to reduce the +5v and TPS out so that you don't rail the input of the Prop ADC. YOU MUST DO THIS. The circuit I posted in my last post contains a voltage divider with 10k resistors.

    If you choose to get an MCP3202 for testing, you STILL need a voltage divider so you don't rail the inputs, since it does not have an external Vref input. The MCP3208 has an external Vref that you can connect to the TPS +5v for proper measurement.

    You have been getting a lot of good advice, but you also need to slow down and be methodical about your design and testing. Right now I get the sense that you try one thing and if it doesn't immediately give your expected result, you go and change something without trying to diagnose what the problem was with your first attempt.

    I had very successful results in designing a datalogging system, but there were challenges and I had to take each on by itself and address them until it worked precisely as I wanted.

    You are facing a learning curve on multiple fronts, slow down and address each part of your design until you are satisfied that you know it well and it is working to your specification. Sometimes this means prototyping a circuit on a small perf board and hooking it up to a multi-meter to validate the design, then testing the other half outside of the specific environment, when they both jive, you bring them together and test it in the environment.

    Here's a picture of the prototype that I put together:

    P0000228_50.JPG
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-01-15 14:33
    Yeah, I do tend to get ahead of myself on quite a few things. You are also correct about if something does not give me the expected results, I switch to something else. With my wallet empty, I cannot afford to purchase an external ADC for testing so I have to use what I can work with. Since the OEM control unit worked simply from the single wire coming from the throttle position sensor, I don't see why I cannot duplicate the results with just that one wire as I did before on the SX using ANALOGIN or RCTIME. Here is what I had for the SX throttle sensor code :

    [php]FUNC getthrottle
    ANALOGIN InPin, OutPin, temp1, 5
    IF temp1 < values1(14) THEN
    temp1 = values1(14)
    ENDIF
    temp1 = values1(13) - temp1
    temp2 = values1(13) - values1(14)
    tmpW1 = temp1 * 100
    tmpW1 = tmpW1 / temp2
    temp1 = tmpW1_LSB
    RETURN temp1
    ENDFUNC[/php]

    Basically, all it did was pull 2 numbers from the eeprom which were previously set. There is a low throttle, then a high throttle variable. Variables : high = values1(13) and low = values1(14). I don't remember how it was hooked up, but there were no more than $0.10 worth of components that I had laying around already. It was accurate to +/- 1% according to my air flow converter.

    Most of the advice I have been getting is great advice! I have already understood more things in just a few days than I ever could have on my own. Some advice requires me to purchase more parts which I cannot do at this moment since I don't have the funding. I figured I would try the ADC function since I already had the parts to put it together. The RCTIME function must have been the first attempt to read throttle and I switched to ANALOGIN for some reason. I just found the code from quite awhile ago.

    Since I plan to release this as a kit to users, I want to make it as simple as possible to wire into their vehicle. When it comes to shielding, I know it will make a difference, but how does the OEM control unit do it without shielding? Is it not possible to duplicate the results from the SX?
  • pedwardpedward Posts: 1,642
    edited 2012-01-15 14:48
    Tim, stick with ADC.spin a bit longer and I think once you resolve 1) remote shielded connection 2) proximity of the ADC components to the Prop pins 3) Voltage divider on ADC input, you will start to see predictable results.

    One little gizmo I designed a while back was a universal ignition interface. It was a circuit that you could couple either via AC or DC, direct or inductive, and it filtered the secondary of an MSD ignition to clean up the noise. I learned that under the hood of the car is a lot of electrical noise. One of the secrets to reducing electrical noise is big conductors. If you have a proper ground point on the engine, and a star pattern ground layout, and you use decently sized hot and ground wires to the engine, you can reduce a lot of noise.

    The factory ECU has 3 wires going to the TPS, you are trying to tap the return from the TPS, while the factory ECU has 3 connections, and they are all nicely bundled together. It's also likely they have both hardware and software filtering on the TPS signal.

    I can't speak to your specific connections because I'm not there scoping things out and measuring values, but you should definitely be able to get a reliable TPS reading. Shielding will give you a more accurate reading without the need to add a bunch of filtering hardware or software, it prevents induced noise from getting into your wires going to the Prop.

    The reason you don't see my Datalogger for sale is because I targeted the same audience you are targeting, but it is a lot more complicated to explain how to hook up 12 inputs than 1 input, not to mention the hack job splicing and other factors like software configuration. I would have to sell it for 4 or 5 times what I originally intended, just to cover the support costs and weed out the people who buy only on price.
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-01-15 15:04
    The engine control unit and the transmission control unit are 2 separate things in my vehicle. I have the full pinout of my transmission control unit which only shows 1 throttle wire input. There are also no 5v inputs or outputs either. I did try to get the ADC to work, but with trying several different resistors, I was not able to get a reliable result from the ADC.spin. I even tried different caps to see if that was my issue. Even with the circuit soldered straight to the development board within 1 inch of the prop, the response was not there that I needed for the throttle input. Even if the numbers returned by the ADC were jumping +/- 50 at 12 bit, I would probably be able to do something with that. The shielding may help, but I did not have the engine running or anything turned on (lights, rad fans, radio, etc...) during 90% of the testing. If the stock OEM unit can do it without shielding, why can't I? What I am thinking about the shielding is it is one more point that could fail during installation for other users.

    I also took apart the air flow converter to see how their throttle input is connected. Interesting enough, there was 1 ceramic cap, and 2 resistors. I can't tell what the value of the resistors are though. Their throttle wire is not shielded either.

    EDIT : The throttle circuit on the air flow converter also goes straight to the main chip. No external ADC.
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-01-15 15:35
    Well, I was wrong on the air flow converter. I missed the trace somewhere and jumped to a different circuit. After retracing as much as I could, it appears the throttle input goes to a 10K resistor which then goes to something that looks like a surface mount transistor. It is connected to the side that only has one pin which I think is the base. It also goes from the base to another 10K resistor which is connected to a cap going to ground as well as to a pin on the main processor. What could that transistor looking thing be doing? Wow...I sound like such a newb :p
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2012-01-15 15:53
    On most SMT transistors (JFETs are the exception) the one-pin-side is the collector/drain. Sounds like they are actually doing an RCTIME type circuit.

    Try this:
                    33.2K                66.5K
             FPIN &#61609;&#9472;&#9472;&#61629;&#61630;&#9472;&#9472;&#9523;&#9472;&#9472;&#9523;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9523;&#9472;&#9472;&#61629;&#61630;&#9472;&#9472;&#61610; VIN
             IPIN &#61609;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9496; &#61612;&#61613;&#61614;.01µ     &#61628; 100K 
                            &#61464;          &#61464; 
    
  • frank freedmanfrank freedman Posts: 1,983
    edited 2012-01-15 15:55
    T Chap wrote: »
    What kind of resolution do you need? If you divided the distance of travel of the throttle by some number of divisions, what is the least amount of divisions you could live with? If for example you could get by with 10 steps, then you could use 5 LM393 comparators, set the ref voltage to each one with 2 resistors(voltage divider), then the throttle can trip each comparator as the voltage gets larger. The Prop could read the 10 comparator outputs and determine which was the highest.

    I have done another trick instead of using the Props ADC or external ADC that will also give a high resolution measuring a voltage.. This requires one part of a comparator( I use a 393). It also requires just a few caps and resistors.

    The idea is, to use the Prop to create a voltage (DAC). I simply use a counter, set a frequency and output a psuedo PWM to create the DAC. Feed the Prop output voltage to one input of the comparator. Then feed the other input of the comp with the throttle(restrict to 3v3). Next, you 'sweep' the output voltage from the Prop to the comp input starting at 0v and rising to 3v3, incrementing the voltage at whatever resolution you want. At each increment(increase in frequency to raise the voltage output), check the comparator output. If it has tripped, then you have exceeded the throttle and know very accurately what the voltage is. This idea is more forgiving on a breadboard than using a ADC method.

    Here is the code I use to set the iTrip value:
    PUB iTRipSet  
         Dira[CurrentTripSetPin] := 1
         outa[CurrentTripSetPin] := 0
         ctrb := 100 << 26 +  CurrentTripSetPin   'dac output
         frqb := 3000
    
         repeat
           phsb := TripLevel      ' this is set on the fly somewhere else.  
    
    

    Now that is a very handy trick to have in ones bag. Hope you don't mind if I add it to mine.......... That is slick!

    FF
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-01-15 15:57
    Ok, I have enough in my paypal account to do a single order of about $35. If i were to order an ADC chip, is there anything else that I will need to order with the chip to get this working correctly? The next function after throttle is the speed sensor which is basically pulses which I think I could read with the freqin function. I will probably need to go SM as well since I will have to order more than one and I plan to keep as much SM components as possible. Will that affect how it is connected on the Prop development board distance wise since I will have to solder single wires to each lead then connect it to the development board?

    What ADC chip will best suit my application? I can either order from Jameco or Digikey.
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-01-15 16:07
    Unfortunately, I don't have a 33.2k or a 66.5k resistor that I know of. I will have to go through my SM resistors to see if I have one. I ordered a 11,200 piece kit from jameco just for this. The problem I have is soldering them to the Prop development board. I have been using some blank PCB boards from radioshack and cutting a small piece to solder the resistor and leads to it. Doing that will increase the distance from the Prop for this application.
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2012-01-15 16:08
    You may want to start building peripheral circuits on something like this: http://www.sparkfun.com/products/8708

    As for ADC, There's already an object for the MCP3208 in OBEX. I'm sure you can find examples that use it in the forums as well.

    33.2K and 66.5K are standard 1% resistors, available from DigiKey. 0402 resistors fit very nicely between holes on a protoboard.
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-01-15 16:17
    The closest resistors I have are : 39.2K, 61.9K and 30.1K. Would any of those work?
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2012-01-15 16:38
    Sorry, I've been awake for too long and don't feel like going through my math again. Basically:

    Define: A || B = (A*B)/(A+B)

    66.5K || 100K = 33.2K

    100K / (66.5K + 100K) = 5 / 3.3

    33.2K was just a convenient value that has a 1% rating, and is within an order of magnitude above the input impedance of your ECU.
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-01-15 16:44
    lol. That just lost me :p In PHP programming || means or. Is this for the RCTIME circuit or ADC? Since I am trying to keep the cost down as much as possible, I want to try and hold off purchasing anything unless really needed.

    Out of curiosity, could I use a 7805 output for bench testing? Basically, have a 7805 wired on it's own connected to the same voltage source, then use a potentiometer to adjust the voltage just like the throttle does?
  • frank freedmanfrank freedman Posts: 1,983
    edited 2012-01-15 18:21
    pedward wrote: »
    Tim, it's been a while since I researched all of the EFI systems out there, but I designed a functional piggyback datalogger for OEM EFI systems. Your car is a Mitsubishi and I would be you have Nippon Denso components in the car. The TPS is a potentiometer, 1 wire to ground, 1 output to the ECU, and 1 to the +5v supply of the ECU.

    First, you are very likely picking up interference from your ignition system, you need to wire up a connection to remove the Prop board from the area. You need a 2 wire shielded cable (they sell rolls at Radio Shack last I checked). Connect the TPS output and +5v to the inner wires, then connect the shield only to the Prop ground. You must also power the circuit from the car, so the car and the Prop are at the same ground potential.

    You MUST only ground the shield at on end.

    Second, the AN008 is specific in that you MUST put the components for the Sigma-Delta ADC very near the prop chip, otherwise you may get undesired results.

    Sigma-Delta is the cheapest way to get ADC on the prop, but the MCP3202 is also a good choice.

    YOU HAVE TO USE A VOLTAGE DIVIDER to reduce the +5v and TPS out so that you don't rail the input of the Prop ADC. YOU MUST DO THIS. The circuit I posted in my last post contains a voltage divider with 10k resistors.

    If you choose to get an MCP3202 for testing, you STILL need a voltage divider so you don't rail the inputs, since it does not have an external Vref input. The MCP3208 has an external Vref that you can connect to the TPS +5v for proper measurement.


    Actually (my opinion only), the MCP3201 is a better choice from the ease of use standpoint. It has a Vref input that can be up to +5V. No code needed to set it up, just provide the CSEL and clk timing from the prop, and at his data rate, it will do fine at 3.3V so no limiting resistors such as I had to use for the 100ksps and Vdd=5V. (object posted in OBEX). In my earlier advise I also suggested an opamp, NTE928, cheap, single supply, and can be found most anywhere. As you are working with only a single input, you should use the MCP3201 if you go to an ADC chip. The 02 chip uses Vdd for Vref. Because the bit value is 4096*in/Vref, you have no flexibility once you have chosen your supply voltage. With the 01, you can choose the Vref independently of Vdd (though Vref can't exceed Vdd). Note that with this series of chip, the max sample rate is determined by Vdd, and for the max rated 100ksps, you need to run +5V Vdd. Both have the possibility of differential inputs, but the 02 requires programming to set up the inputs, the 3201 is a single differential input. Run one lead from (+) input to TPS wiper, (-) to low side of TPS, and use the differential mode to eliminate much of the common mode noise assuming that the ECM is providing a +5V reference. You will need to provide a series resistor between the data out pin and the prop, though the prop outputs seemed to work fine for me (Vdd +5V) with the Csel and clk as they are output only.

    In looking up a couple of things for this reply, there are two notes in the MCP data sheet to watch out for if you go this route. 1)min clock rate 10khz, and 2) linearity of the conversion depending on he Vref value.

    As to the 3208, its price is about double the price of the 3201 at digikey.

    Just a couple of thoughts if you decide to avoid the layout issues with S/D form of analog to digital conversion.

    Frank
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-01-15 18:26
    I am back to attempting the ADC again before I order parts. I am using the ADC.spin which comes with the 1.2.6 Prop Tool. What I have done is read up a little more on the ADC functionality and have used the calculator found here : http://www.pulsedpower.net/Applets/Electronics/SigmaDeltaADC/SigmaDelta.html to figure what resistor values I need.

    Before I start soldering things down, I would like to clarify a few things that I am unsure about.

    According to the above calculator, using a 100K resistor in place of the 150K in the basic circuit provided on the same page as the calculator, the max input voltage would be 3.3V and the minimum would be 0. I will also use a 10k resistor from the TPS signal to the 100K and another 10K connected between the two to ground giving me the voltage divider.

    I have attached a schematic of what I am thinking will work.

    1 . Since my range I need to read from is 0.51v to 5.00v, would the 100k make a difference?

    2. Since I am using the Prop development board (the one without the breadboard), would the ADC function work on it as long as I keep the 100K and the 2 caps within the first 2 connecting points for each pin?

    3. Will there be a difference in accuracy from using SM components to DIP components?

    4. Should the Vdd of the circuit be connected to the 5v rail or the 3.3v rail? I am using a voltage divider resistor to bring the 5v down to 2.5v.

    Any help is appreciated! I have been battling this for 2 straight days now :(
  • frank freedmanfrank freedman Posts: 1,983
    edited 2012-01-15 18:39
    lol. That just lost me :p In PHP programming || means or. Is this for the RCTIME circuit or ADC? Since I am trying to keep the cost down as much as possible, I want to try and hold off purchasing anything unless really needed.

    Out of curiosity, could I use a 7805 output for bench testing? Basically, have a 7805 wired on it's own connected to the same voltage source, then use a potentiometer to adjust the voltage just like the throttle does?


    || in electronics speak is Rx in parallel with Ry

    FF
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-01-15 18:54
    pedward wrote:
    YOU HAVE TO USE A VOLTAGE DIVIDER to reduce the +5v and TPS out so that you don't rail the input of the Prop ADC. YOU MUST DO THIS.
    That is simply not true. You do not need a separate divider ahead of the sigma-delta ADC circuit. The input voltage range is determined by the ratio of the input resistor to the feedback resistor. (A 270K input resistor and a 100K feedback resistor will accommodate a 0-5V range with margins at both ends.) What you do need is a way to calibrate the ADC ahead of taking readings. For this, I would suggest using a 3:1 or 4:1 analog multiplexer ahead of the ADC input, so you can switch in +5V, 0V, and your analog input. A look at the source code for the S2 Robot's driver object (S2.spin) will show how to scale the integration time to provide $00 - $FF outputs from a 0 - 5V input range.

    -Phil
  • pedwardpedward Posts: 1,642
    edited 2012-01-15 19:03
    You do not need a separate divider ahead of the sigma-delta ADC circuit.

    -Phil

    Agreed.
  • frank freedmanfrank freedman Posts: 1,983
    edited 2012-01-15 19:19
    I am back to attempting the ADC again before I order parts. I am using the ADC.spin which comes with the 1.2.6 Prop Tool. What I have done is read up a little more on the ADC functionality and have used the calculator found here : http://www.pulsedpower.net/Applets/Electronics/SigmaDeltaADC/SigmaDelta.html to figure what resistor values I need.

    Before I start soldering things down, I would like to clarify a few things that I am unsure about.

    According to the above calculator, using a 100K resistor in place of the 150K in the basic circuit provided on the same page as the calculator, the max input voltage would be 3.3V and the minimum would be 0. I will also use a 10k resistor from the TPS signal to the 100K and another 10K connected between the two to ground giving me the voltage divider.

    I have attached a schematic of what I am thinking will work.

    1 . Since my range I need to read from is 0.51v to 5.00v, would the 100k make a difference?

    2. Since I am using the Prop development board (the one without the breadboard), would the ADC function work on it as long as I keep the 100K and the 2 caps within the first 2 connecting points for each pin?

    3. Will there be a difference in accuracy from using SM components to DIP components?

    4. Should the Vdd of the circuit be connected to the 5v rail or the 3.3v rail? I am using a voltage divider resistor to bring the 5v down to 2.5v.

    Any help is appreciated! I have been battling this for 2 straight days now :(

    1. with the divider shown in your drawing, you will have a max of 2.5V at the tap between the 10k resistors. your system will need to assume the value seen for 2.5V is the 100% value and scale the values down from there in software. If you want the full range, you would need to recompute the values. Use say 22000 and 33000 for the divider, giving 2V a 0 - 3.0 volt range on the divide point. The resistors are standard values. Then feed the voltage into this circuit from the gadget gangster pages.

    http://www.gadgetgangster.com/tutorials/382

    I also looked at your ref link above, and see what you used for the calc. If you use the divider you plan with the resistor values 22k over 33k, then you could use the circuit they show with the two 100k resistors as you will not see >3.0V at the input to the actual ADC part of the circuit. Their recommendation of 150K is to limit the max voltage on the input pin of the prop (3.3V max) .

    2. ? not using that board.

    3. Should not be for active devices, don't think enough to make a difference in resistors, consult the data sheets for the drift in capacitor values.

    4. 3.3 V

    Thoughts only on the ADC part of it as I just went with ADC chips to play with. MCP3201s I bought to play with to get a feel for before the ongoing curve tracer project, and experimenting with ADC systems design.

    Non-expert opinions for sure,

    Frank
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-01-15 19:34
    I went ahead and built the circuit on the development board using pins 8 and 9. They seem to be the closest ones to the prop that were still available on my board. I used SM resistors and DIP caps. The entire circuit can be covered with a dime. I have set the ADC to 16 bit output and it is staying + / - 100 on any voltage from 5v to 0v.

    I saw a post earlier that was supposed to get an average of something, but I have no idea how to use it. I guess what I am needing to do is to get an average of the specific reading during a specific time period and output the average as the "throttle" variable. How would I do this in SPIN?
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2012-01-15 20:13
    Here is a very rudimentary lowpass filter.

    Pseudo code:
    repeat a = 0 to 127
      Myval *= 0.9
      Myval += 0.1 * ADC.read()
    
  • chetw77cruiserchetw77cruiser Posts: 12
    edited 2012-01-15 20:25
    The averaging that I was referring to is a function built into the MCP3208 object. I would imagine that you could use the pub method in your app with a bit of thought. Here is the section of code I am referring to. Keep in mind that there is other associated code that goes with this and that this is for the adc mcp3208 chip. I find this chip easier to use and less parts needed for 8 channels with 12 bit accuracy. This might help if you do decide to use this chip. Worked for me.

    http://gadgetgangster.com/tutorials/397
    PUB average(channel, n) : sample | c
    
    '' Average n samples from an ADC channel (0..7)
    
      c := count
      repeat n
        repeat while c == count
        sample += ins.word[channel]
        c++
      sample /= n
    
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-01-15 20:29
    I was thinking about using an array and another cog or calculate it in the main loop. Basically, have the cog do nothing but update variables as fast as the clk frequency. I could sample 10 readings or so then add them up and divide by 10 to get the new throttle value. I am going to try to figure out how to write an to an array, then use the variables in it. I think it is similar to PHP by doing something like this :

    [PHP]
    LONG ThrottleArray[9] ' 0 through 9
    BYTE averagecounter

    averagecounter := 0

    repeat
    ThrottleArray[averagecounter] := adcsample
    averagecounter++
    if averagecounter == 9
    averagecounter := 0
    'somehow sum array then divide by 10
    throttle := array average
    endif
    [/PHP]

    I may have mixed some languages there... I am on my other computer right now that does not have the prop tool on it so it is off the top of my head.
Sign In or Register to comment.