Shop OBEX P1 Docs P2 Docs Learn Events
RCTime in SASM — Parallax Forums

RCTime in SASM

NateNate Posts: 154
edited 2005-05-27 15:19 in General Discussion
Hi all,

I'm trying to use a AD592 (temperature dependant current source, thermometer) with a SX using SASM.· The circuit is the typical resistor/capacitor circuit used with RCTime (AD590 from Vdd to node that has 100 ohm resistor to SX I/O pin and 0.1 uF Cap. to Vss, see atachment)

The code snippet is below.··Pause1000 is a 1 second delay routine, rct1 is a 8bit variable, AD590 is defined as rb.7, the pin which the AD590 is attaced to, SX is running off SX-key (4 MHz)·on the SX-tech board.

The problem is that·the program·returns values close to what I would expect in the variable rct1, but every loop through the code gets a slightly different value for rct1 (eg. 217, 220, 218, 222, etc)·

I have used the exact same circuit with a BS2 and the PBASIC RCTime and always get the same value for rct (247).

Does anyone have any ideas·as to why SX is giving me this·'jumpy' RCtime?



senseAD592
·clr··rct1······················ ;clear the rtc var
·mode·TRIS
·mov··!rb,·#%01111111···;rb.7 to output, set to 0 (low)
·clrb·AD592·················· ;make rb.7 low (drain cap)
·call·@Pause1000·········· ;time drain the capacitor
·mov··!rb,·#%10000000···;set rb.7 to input (let cap. start charging again)
rctime
·snb··AD592················· ;check the pin to which the AD590 is attached to
··jmp·rct_done·············· ;when rb.0 goes high, get out
·inc··rct1····················· ;increment the counter
·nop··························· ;running with 4 MHZ clock, want 8 CC per loop (2us)
·nop
·nop
·jmp·rctime

rct_done····················· ;when done, wait a bit and start again
·call·@pause1000
·jmp··senseAD592


Thanks in advance for any ideas.

Nate
«1

Comments

  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2005-05-16 19:50
    Nate,

    when you use the SX-Key as clock source, there is some jitter in the clock generated by the SX-Key. This is because the SX-Key makes use of a PLL clock generator to be able to generate the various posible clock frequencies.

    Try to program the SX-Chip for stand-alone operation (Run - Program), and insert a 4 MHz resonator in the socket on the SX-Tech board, and see what happens then.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
  • BeanBean Posts: 8,129
    edited 2005-05-16 20:02
    Do you have any RTCC interrupts ? They will cause jumpy reading also.
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video Display Module" Available Now.

    www.sxvm.com

    "It's not getting what you want, it's wanting what you've got."
    ·
  • NateNate Posts: 154
    edited 2005-05-16 20:30
    Gunther,

    Using a resonator seemed to help a lot, the RCTime variations now only have a range of ~5 over several minutes of operation (ie 180 samples).·

    I am using the "OSCXT2" directive, a 4Mhz resonator (Murata) with 1Mohm Rp.· I would expect this to be more consistant than it is, as the temperature of the AD590 and the resonator are being held pretty constant.· I guess the next course of action is to try a crystal.· (I'm tying to measure temperature, and +/- 2.5 C is a little more than the application can tolerate).

    Bean,

    I have cut down pretty much my whole program tying to find out what is causing this error, pretty much what I gave is the whole program except for the header and compiler directives.

    Actually, one reason I didn't suspect the SX-Key timing was that I saw that you had used a 50MHz resonator in your video signal generator, and I thought if you could get away with doing your video timing using a resonator, they must be pretty stable.

    Have·you by any chance·used an RCtime-type circuit and been able to get more consistant results with the SX?

    Nate
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2005-05-16 21:54
    Nate,

    good to hear that my resonator tip did help at least a bit.

    If power consumption is not an issue, you might consider to clock the SX at a higher rate (up to 50 MHz), giving you a better resolution by a factor of 12.5 - yes, I know that this requires "some" changes in your code.

    Another idea would be to use an RTCC roll-over controlled interrupt service routine to handle the timing issues. Well-designed ISRs can be a real "booster" for the SX smile.gif .

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
  • NateNate Posts: 154
    edited 2005-05-16 22:58
    Actually I already did the switch to a higher resonator speed - I thought the higer resolution would give me less jitter too, but I still have about the same amout of variance, about +/- 2.5 for a decent number of samples.· I have gone over my code many times and do not think it is caused by that - the loop that increments the rtc counter is a consistant number of clock cycles.· I have replaced the AD592 with·a 20K ohm resistor and still have jitter.·

    I am beginning to wonder how the BS2 is so consistant with the values it returns to the RCTime.·

    I will asssume that if you have the same R and C values, and consistant voltage, then really the only variable is the timer that times how long it takes the cap to charge.· (The only other thing that I can think of is that the threshold voltage for the SX to call a pin 0 or 1 fluctuates slightly.)

    I am in the process of converting the circuit to use a crystal and see if that makes any difference.

    If there is anyone out there that wrote a RCTime routine for the SX that did not have problems with consistancy, please let me know.

    Nate
  • BeanBean Posts: 8,129
    edited 2005-05-16 23:14
    Nate, I noticed that don't have any code to output the value in rct1. How are you reading the values ?
    Are you using the debugger ? If so that may be the cause of the fluctuations.
    Or is rct1 a port and your reading it right from the port ?

    It is helpful to post the complete program.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video·Module" Now available from Parallax for only $28.95 http://www.parallax.com/detail.asp?product_id=30012


    Product web site: www.sxvm.com

    "It's not getting what you want, it's wanting what you've got."


    Post Edited (Bean (Hitt Consulting)) : 5/16/2005 11:50:54 PM GMT
  • NateNate Posts: 154
    edited 2005-05-17 01:44
    Bean,

    rct1 ia a variable.· I send that variable out ra.0 to HyperTerminal.· Attached is the larger program code.· At this·point in time I have used comment lines and jumps to narrow the program down to the code that I posted in the beginning and the routines that allow me to send the variables to the serial HyperTerminal connection.

    I'm still getting pretty large (+/-3, sometimes more) fluctuations in the rct1 variable.· The RCtime circuit I am using is now the most simple I can make, 20 kohm resistor from Vdd to node, node has 100 ohm resistor to rb.7, .22uF cap. to·to Vss.

    I'm going to redo the math and try a crystal next.

    Nate
  • BeanBean Posts: 8,129
    edited 2005-05-17 02:10
    Nate, I would think the jitter is caused by the RC circuit and not by the SX clock. I would expect some jitter, but I can't explain why the BS2 does have any ???

    Bean.

    Edit: Have you checked for noise on the supply ? That could cause the jitter.

    Bean.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video·Module" Now available from Parallax for only $28.95 http://www.parallax.com/detail.asp?product_id=30012


    Product web site: www.sxvm.com

    "It's not getting what you want, it's wanting what you've got."


    Post Edited (Bean (Hitt Consulting)) : 5/17/2005 2:13:23 AM GMT
  • pjvpjv Posts: 1,903
    edited 2005-05-17 03:20
    Hello Nate;

    I was just having apeek at your code and noticed a problem unrelated to what you are describing.

    In the WRITEDS1620 routine you have two (possibly 3) consecutive port accesses for wiggling the data and clock lines. At the 50 MHz processor speed that is an invitation for trouble; youn need to separate them by at least one (nop?) instruction. At slower speeds what you have is acceptable, but not at high speeds.

    I have not looked at the balance of your code to help you with the problem you describe.

    Peter (pjv)
  • NateNate Posts: 154
    edited 2005-05-17 13:04
    Bean,

    Was running the SX-board from a wall wart, switched to a regulated DC Bench power supply on a different 110V circuit - still had jitter.

    Also tried the same program with a crystal clock oscillator (3.5795 Mhz, had to change the program timing slightly) and still had the jitter.

    I wrote a quick program to do what I'm doing in SX/B using the RCTime instruction in that environment (SASM output file is pretty much the same as mine, but wanted to see if there was something I was missing), ran the program, and got the same jitter.·

    Then I took the circuit (exact same components) and attached it to a BS2 (using same power supply).· The BS2 gives me rctime readings close to those given by my SASM programs, but it was rock solid, no jitter!!· What magic is the BS2 using that I'm not putting (and SX/B doesn't use either) in my SASM code?

    Peter,

    Thanks for the heads up, the program was really written to be used at 4MHz, I just have been trying many different things to get the RCTime portion of the program to work and not really been keeping the rest of the program up to date.· If the higher speed had made the RCTime work, I'm sure I would have spent days trying to figure out why the DS1620 portion was not working [noparse]:)[/noparse].

    Nate
  • BeanBean Posts: 8,129
    edited 2005-05-17 13:34
    Nate,
    Do you have a scope to look at the supply ? The SX could make more noise that an BS2.
    If you can put a coil is series and a cap to ground on the supply to the RC circuit.
    Or try running the RC circuit from a different supply (with a common ground).
    You see the input pin switches at 1.4 Volts, but if there is noise it will "see" 1.4 volts at different times.

    There is no magic code that the BS2 is doing. That's why it must be something else.
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video·Module" Now available from Parallax for only $28.95 http://www.parallax.com/detail.asp?product_id=30012


    Product web site: www.sxvm.com

    "It's not getting what you want, it's wanting what you've got."
    ·
  • NateNate Posts: 154
    edited 2005-05-17 16:55
    Mystery finally solved.· Bean, you were on the right track.·

    I tried the program with independent supplies to the SX and the RC circuit, but still no dice.·

    So now I try an entirely different protoboard with a new SX, new Voltage regulator, independent supplies etc, etc.· Still getting the jitter

    So, I'm sitting there staring at the BS2 and the SX-tech board, looking for the magic component on the BS2 Boe board that is allowing it to do what the SX-tech board setup cannot do, because I know it is doing something magic.· And now I know magic comes in little cans that say 1000uF on the side.· The SX-Tech board doesn't have enough built-in capacitance on the power supply (ie stability)·to run a RCTime function in a repeatable manner.· I stuck a 1000uF cap between the Vss and Vdd terminals, and the program worked slick as,..·well you know.

    Sigh..another 3 hours spent on a problem that I should have solved in about 10 minutes......Thanks to all·who gave some inputs.

    Nate


    Post Edited (Nate) : 5/17/2005 6:35:56 PM GMT
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2005-05-17 18:24
    Nate,

    thanks for sharing this experience.

    Maybe, this is the cause for another phenomenon, I have experienced with the SX-Tech board:

    About 4 out of 10 times, I get a "Device Connection Failed" error when I try to program an SX sitting on the SX-Tech board. Since I'm proud owner of a Professional Development Board, I have programmed the SX sitting on this new board quite often, and I never got the error message when using this board.

    I'll attach a 1000µF cap to the SX-Tech board, and see how the SX behaves during programming then.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    Günther
  • BeanBean Posts: 8,129
    edited 2005-05-17 18:54
    Congratulations.
    Thanks for sharing the solution. Guenther, your right about the SX-Tech board. When I program my video modules I never get the "Device Connection Failed" that I get with the SX-Tech board.
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video·Module" Now available from Parallax for only $28.95 http://www.parallax.com/detail.asp?product_id=30012


    Product web site: www.sxvm.com

    "It's not getting what you want, it's wanting what you've got."
    ·
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2005-05-17 19:24
    Terry (Bean),

    good to know that I'm not the only one experiencing the "Device Connection Failed" message. I did not try the 1000 µF cap yet but will do, and report the results.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    Günther
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-05-17 20:21
    Hello All,

    ·· Regarding the "Device Connection Failed" messages.· I conveyed this to one of our engineers who suspects this is related to a weak power supply.· I would add that this could also happen depending on what else the power supply is driving besides the SX-Key and the SX Chip, which already consume quite a bit.

    ·· The bottom line is that the recommended power supply for the SX-Tech board for programming is 7.5 Volts and at least 1A.· Anything less and you're likely to see this happening (This can be confirmed with a Scope).· The capacitors are most likely simply compensating for another existing problem, which is the weak supply.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • KenMKenM Posts: 657
    edited 2005-05-18 02:08
    Nate,
    Even though that was three hours, the time was well spent. You learned something that you will not soon forget.
    Nate said...
    Sigh..another 3 hours spent on a problem that I should have solved in about 10 minutes......Thanks to all·who gave some inputs.
    Nate

    Post Edited (KenM) : 5/24/2005 7:12:10 PM GMT
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2005-05-24 11:29
    Chris, and the gang,

    yesterday, I had to program 50 SX28 devices. I used the SX-Key and an SXTech boad for programming. While programming the first 25 chips, I used the "plain" SXTech board, and got about 10 "Chip Connection Failed" errors. Then I connected a 1000 µF capacitor between Vdd and Vss. With this setup, I could program the remaining 25 devices with no more "Chip Connection Failed" errors.

    BTW: I'm using a 9V power supply rated at 1.1 A.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    Günther
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-05-24 14:57
    Guenther,

    ·· Thanks for the information.· I don't have an explanation for why this would happen.· The power supply you're using should be more than adequate to prevent those errors from happening.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2005-05-24 16:39
    Chris,

    if you look at the SX Tech Board schematic, you will notice that the capacitor on the output side of the LM2940-5.0 is a 1µF Tantalum. My assumption is that this capacitor is not large enough to filter out spikes that might occur when the SX-Key turns on the on-board DC/DC converter to generate the Vpp voltage (around 12V) for programming the SX device. Buffering the supply voltage with an additional capacitor across Vdd and Vss (like the 1000 µF I used) seems to solve that problem, so it's an easy fix.

    As a matter of fact, when using the SX Tech Board to drive servos, like in the SX Tech Bot examples in my book, it was even necessary to use a capacitor of at least 3,300 µF to buffer the regulator output in order to filter the spikes generated by the servos when they begin to move or change direction. Without such a capacitor, it can happen that Vdd drops low enough to cause the SX to perform a reset when the servos "eat up" additional current.

    Seems as if the LM2940-5.0 can't handle fast load changes too well, so it's a good idea to always use an additional filter capacitor across Vdd and Vss with the positive (longer) lead connected to Vdd, and the negative (shorter, and mostly marked with a stripe on the metal canister) lead to Vss.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    Günther
  • ForrestForrest Posts: 1,341
    edited 2005-05-24 17:49
    This is copied straight out of the LM2940 Data Sheet:

    EXTERNAL CAPACITORS The output capacitor is critical to maintaining regulator stability, and must meet the required conditions for both ESR (Equivalent Series Resistance) and minimum amount of capacitance. MINIMUM CAPACITANCE: The minimum output capacitance required to maintain stability is 22 μF (this value may be increased without limit). Larger values of output capacitance will give improved transient response.

    Why is the output capacitor on the SXTech Board 1uF?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-05-24 19:16
    Hello,

    · Sorry it took me so long to reply, but I decided to handle this by programming 35 SX28 chips using the SX-Tech board.· 15 were done on the same SX-Tech board (Which is one of our first), and the rest were done in groups of 5 across 4 more SX-Tech boards from different times.· Not one single error during programming or communication occurred.· I used the standard 7.5V 1000mA power supply we carry on all of them.·

    ·· We have sold thousands of these devices and never had any issues with this board before.· All I can guess is that there must be some unique set of circumstances affecting the few people now mentioning this problem.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • John BJohn B Posts: 82
    edited 2005-05-24 22:32
    Hi there,

    The SX-Tech board was originally designed with a 22uF cap on the regulator's output. How·the value changed to 10uF is a bit of a mystery, though it appears that it has been a 10uF cap for at least 3 years.· Usually, an error like this results in a loud public outcry and (sometimes a mob-scene) until we correct it.· The fact that this problem has such a narrow focus leads me to believe that your trouble may lie elsewhere.·

    Are you able to remove the 10uF cap and replace it with a 22uF 6VDC cap?· If you can do this and use the board in·for a while·we might be able to determine the cause of the problem.· If the SX-Tech board programs without error, then the trouble was due to the lack of the regulator's ability to regulate with 10uF of load capacitance.· If the problem persists, then the most likely culprits·is the power supply.· If the power supply is beyond suspicion, then perhaps there is something amiss with your SX-Key.· Where ever the trouble lies, with your help, we can find it.

    I have completed the requisite ECM to change the BOM to ameliorate this issue.· If you have the interest and don't mind participating in this experiment, you can help us isolate the problem.· At this point, it may be only academic, but it is fun nonetheless.

    John Barrowman

    Engineering

    Parallax, Inc.

    www.parallax.com
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2005-05-24 23:17
    John,

    posting my experiences with the SX-Tech board with or without an additional filter capacitor was not meant to generally criticise the board design. I only wanted to share my experiences with the SX community and I also wanted to show an easy solution how to avoid problems like "Chip Connection Failed" errors by simply adding an extra filter capacitor in case anybody else should be faced with this problem.

    BTW: You mentioned that the SX Tech board was originally designed with a 22 µF filter cap on the regulator's output - I'm pretty sure that this would do the job. On the other hand, all the SX Tech boards I have here (I've got some of these) only have a 1 µF cap on the output side - not even the 10 µF cap you had mentioned.

    As I said before, this is not a big deal - you can always "plug in" an additional cap into one of the available Vdd/Vss header sockets, or remove the original 1 or 10 µF cap from the PCB and replace it with a 22 µF (or higher) cap - this is what I just did on one of my SX-Tech boards. I'll be using this one for the next series of SXes to be programmed soon, and will let you know the results.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    Günther
  • John BJohn B Posts: 82
    edited 2005-05-24 23:38
    Hi there,

    Fear not; no offense was taken.· My concern·is to·identify the problem and correct it.· Yes, please let me know what you find when you change the capacitor to a 22uF.·

    The fact that you have SX-Tech boards stuffed with a variety of cap values shows that we've had production problems with this pcb for some time.· Please accept my apologies.· We work hard to deliver a quality product. I will work with our production personnel to see that this problem is terminated.

    Again, thanks for pointing this out to us.

    John Barrowman
    Engineering
    Parallax, Inc.
    www.parallax.com
    ·
  • ForrestForrest Posts: 1,341
    edited 2005-05-25 01:40
    My SXTech board has a 10UF 50V electrolytic cap on the input side (C1) and a tantalum cap marked 7501 on the output side (C2). I've had no problems programming SX28 chips with the 7.5V 1A power supply supplied by Parallax.

    Guenther, I'd be interested to know the results of your experiment.

    Maybe we should start a new topic.
  • PJMontyPJMonty Posts: 983
    edited 2005-05-25 02:13
    Chris,

    There have been numerous people who have had the mysterious "Chip connection failed" pop up on them. I have experienced it myself. I think most folks don't mention it because it happens and then it's gone. The transient nature of it usually makes it more of an annoyance than a real problem... unless you're programming 25 parts in a row like Guenther!
      Thanks, PeterM
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2005-05-25 07:44
    John, Forrest,

    the output capacitors on my SxTech boards also are tantalum caps marked 7501. I have measured its capacity, and the meter shows 1 µF. BTW: The schematic of the SXTech board shown in the SX-Key Ver. 2.0 manual on page 147 also specified the output cap C2 as 1 µF tantalum.

    In the meantime, I have removed the cap from one board and replaced it with a 22 µF. I'll have to program another series of SXes in the next days, and I#ll let you know the results then.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    Günther
  • pjvpjv Posts: 1,903
    edited 2005-05-25 18:27
    Hi Guys;

    OK, so here is a twist in my experience.... since 1998 I have (re)programmed SX's thousands of times and the occasional "Chip connection failed" message has come up, and that has been with my own boards as well as with Parallax boards.

    The common thing in my experience has been that the 4 pin SXKey connector has been worn so much that a poor connection is made from time to time. All I do is wiggle it a bit, or if the problem is more persitent, then re-plug the Key to the 4 pin header, and away we go. I can positively state that at no time was there ever a power supply/capacitor issue; always a poor connection.

    When things become too troublesome, I replace the Key's connector, and I'm good for a year or more.

    I have a suspicion that some of these posts may also be due to the same problem.

    Cheers,

    Peter (pjv)
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2005-05-25 20:19
    Peter,

    I agree with you that bad connections can also cause a "Chip connection failed" error. As a matter of fact, I got this message today when I forgot to insert an SX chip into the SX Tech Board when I tried to program the device - Arghhh.

    Nevertheless, I don't believe that my recent experience with frequently piling up "Chip connection failed" errors was caused by bad connections because I've been using a brand-new SX Tech board (but one with with a 1 µF output filter cap), and a brand new SX-Key.

    Seems as if there are at least two reasons for the "Chip connection failed" error.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    Günther
Sign In or Register to comment.