Shop OBEX P1 Docs P2 Docs Learn Events
Changing Propeller clock — Parallax Forums

Changing Propeller clock

NewzedNewzed Posts: 2,503
edited 2007-08-24 23:21 in Propeller 1
I have a feeling the Prop clock is too fast for my TLC2543.· How can I change the Prop clock from 80mHz to, say 20mHz?

Sid

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Yesterday is history, tomorrow is a mystery, and today is a gift.

That is why they call it the present.

Don't have VGA?
Newzed@aol.com
·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-08-22 13:57
    Sid,
    It would be very unusual for the Prop's clock to affect the peripherals since the Prop program controls the speed of everything sent out. It's more likely that your program where it produces whatever clock it's using for the TLC2543 is the culprit. I know you've had other threads where you've talked about this TLC2543, but you didn't mention here what kind of driver you're using.
  • NewzedNewzed Posts: 2,503
    edited 2007-08-22 14:09
    Mike, I am using the shiftin/shiftout methods from Martin Hebel's BS2.functions.· The problem is, when I load the program and read the ADC, it takes about 50 iterations of the shiftin/shiftout methods before the ADC displays the expected temperature.· Once the ADC reading gets to where it should be, the readings are accurate until I reload the program, then it goes thru the iteration process all over again.· I posted the program I am using in the TLC2543 thread.· I have done everything I can think of - even inserting a short waitcnt between the shiftin and shift out, but I just can't correct the problem.· I hope you have a suggestion.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Yesterday is history, tomorrow is a mystery, and today is a gift.

    That is why they call it the present.

    Don't have VGA?
    Newzed@aol.com
    ·
  • rjo_rjo_ Posts: 1,825
    edited 2007-08-22 15:21
    Sid,

    I found several posts to other forums, which were very interesting, but not the original. Could you point me to the thread that contains your program and circuit diagram?

    You are reporting an issue that sounds like my experience using the RC example from the counters lab in the Propeller Education Kit, where there is what a biologist would call "hysteresis..." in which there is a "range" error in both RC time measurement and the and the settling time to reach a stable RC time, both of which are inversely related to a resistance threshold for a fixed capacitance.

    ("Hysteresis" is also an engineering term and I'm not sure I'm using the term correctly in this context:,] )

    Since the TLC2543 uses an RC technique with switched capacitance... if your error is of the same nature, then I would expect that there is some mismatch between resistance and capacitance somewhere...

    What happens when you vary the external voltage?

    You mention a pattern of errors... are they generally underestimates? What are you using for your gold standard? How much accuracy are you looking for?

    Rich
  • Tracy AllenTracy Allen Posts: 6,660
    edited 2007-08-22 15:53
    Sid,

    It sounds to me like perhaps you have a temperature sensor attached to channel X but your program is reading channel X+1, which is floating. The floating channel will gradually approach the reading on the neighboring channel due to gate leakage.

    Other points. When the TLC2543 first wakes up from its sleep state or first powers up, take and discard one reading from any channel. That first reading may be bogus. Remember that SHIFTOUT and SHIFTIN are always concurrent with the TLC2543, so when you shift in the result of the previous conversion, whatever is on the shift out pin is setting up a new conversion.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • JonathanJonathan Posts: 1,023
    edited 2007-08-22 16:32
    Sid,

    I have found what Tracey says above: the first reading is usually junk. Other than that, the TLC2543 works great with the Prop for me. I have used both the BS2_functions and SPIengine with success.

    Jonathan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
  • NewzedNewzed Posts: 2,503
    edited 2007-08-22 17:12
    Jonathan, I know about the first junk reading with the 2543.· I have built lots of them for the Stamp and what Tracy says is true.· Do you have a copy of your program using BS2.functions?· I'd like to compare it to mine and see if I have done something wrong.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Yesterday is history, tomorrow is a mystery, and today is a gift.

    That is why they call it the present.

    Don't have VGA?
    Newzed@aol.com
    ·
  • NewzedNewzed Posts: 2,503
    edited 2007-08-22 20:24
    Tracy, I disconnected everything and worked on another project.· After lunch I hooked everything up again, and now the channel I have my sensor plugged into - Channel 1 - gave me two bad readings, then started displaying the proper value - no priming required.· If I stop the reading, then call it again, the first reading is right on.· The strange thing is - if I change the program to select any other channel with the sensor still plugged into Channel 1, I immediately get the same readings as when the program selected Channel 1.· All but Channel 0 - that channel reads 0· whether not the sensor is plugged into it - it must be dead.· Would you have expected the same readings on all channels?

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Yesterday is history, tomorrow is a mystery, and today is a gift.

    That is why they call it the present.

    Don't have VGA?
    Newzed@aol.com
    ·
  • NewzedNewzed Posts: 2,503
    edited 2007-08-22 22:08
    Tracy, I just plugged the ADC module into my Stamp and it works perfectly, even Channel 0 reads correctly.· Maybe I have a bad board - I'm going to switch to the Proto Board and see what happens.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Yesterday is history, tomorrow is a mystery, and today is a gift.

    That is why they call it the present.

    Don't have VGA?
    Newzed@aol.com
    ·
  • Tracy AllenTracy Allen Posts: 6,660
    edited 2007-08-22 22:27
    Sid,

    It would be typical for all of the floating channels to gravitate toward the one that has a stiff voltage applied from the temperature sensor. Internal capacitors are sampling the inputs and moving the charge around, and if nothing is attached to an input, the input capacitance would become charged to a level determined by the internal sampline process. There may be resistive leakage between the channels too. I'm not sure why your channel 0 is acting differently and reading zero, but I doubt the "dead" theory. Maybe it is hooked to ground or there is a leakage path to ground? Have you tried it with the temperature sensor attached to channel 0? Change the order that your channels are scanned and see if that changes the result.

    Also, recall that when you read the data with the BS2 shiftin method, the value shifted out to the TLC2543 at the same time is probably a %000000000000, which effectively starts a conversion on channel zero when ychip select goes high. That happens any time you read any channel, 0 to 13, so channel zero gets a lot more conversions than the other channels. It is possible to write a method specifically for the TLC2543 that streamlines the data acquisition so that every shiftin is accompanied by a meaningful shiftout to start the next conversion.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • NewzedNewzed Posts: 2,503
    edited 2007-08-22 22:58
    Tracy, the Proto Board works exactly like the other board.· Regarding Channel 0, I wrote:

    bs.shiftout(din,clk, bs#MSBFIRST,0<<8,12)

    and Channel 0 read 0.· Then......I wrote:

    bs.shiftout(din,clk, bs#MSBFIRST,1-1<<8,12)

    and Channel 0 read just like the other channels.· Then I wrote:

    bs.shiftout(din,clk, bs#MSBFIRST,(1-1)<<8,12)

    and Channel 0 read 0 again.· Can you tell me what is going on?· What is the difference between 1-1 and (1-1)?· I wrote:

    bs.shiftout(din,clk, bs#MSBFIRST,(1)<<8,12)

    and the readings were normal.· Maybe 1-1 doesn't = 0 but (1-1) does.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Yesterday is history, tomorrow is a mystery, and today is a gift.

    That is why they call it the present.

    Don't have VGA?
    Newzed@aol.com
    ·
  • Tracy AllenTracy Allen Posts: 6,660
    edited 2007-08-22 23:54
    Sid,

    The shift operator << has priority over subtraction, so {1-1<<8} is equivalent to {1 - (1<<8)} not {(1-1) << 8}.

    What happens if you attach the temperature sensor to channel 0 and read it there?

    What reading do you get from channel 11? That is the internal Vref/2 reference signal.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • NewzedNewzed Posts: 2,503
    edited 2007-08-23 00:13
    Tracy, if I plug the sensor into Channel 0 and change the program accordingly, I get 0 for a reading.· Channel 0 works perfectly when I plug the module into my Stamp/

    Channel 11 is not connected so I can't read that.

    Maybe the BS2.shiftout won't accept 0<<8 - I sent Marting Hebel an e-mail asking him about that.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Yesterday is history, tomorrow is a mystery, and today is a gift.

    That is why they call it the present.

    Don't have VGA?
    Newzed@aol.com
    ·
  • Tracy AllenTracy Allen Posts: 6,660
    edited 2007-08-23 07:23
    Channels 11, 12 and 13 are internal connections, inside the TLC2543, and you can always read them. Channels 0 to 10 are connected to external pins. Channel 11 is connected internally to Vref/2, so it should always read 2047 or 2048 counts.

    Other things to do with channel 0:
    - measure the voltage there with a voltmeter, to be sure it is not shorted to ground on the protoboard (but okay with the Stamp)
    - connect channel 0 to +5 or to +3.3 volts and see what it says.
    - connect the temperature sensor to both channel 1 and to channel 0 with a jumper and see if they are still different.

    Pretty mysterious all right!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • NewzedNewzed Posts: 2,503
    edited 2007-08-23 12:20
    Good morning, Tracy

    Problem solved!!· It was the BS.shiftout structure.· I had written:

    bs.shiftout(din,clk,bs#MSBFIRST,adch<<8,12)

    and it should have been:

    bs.shiftout(din,clk,adch<<8, bs#MSBFIRST,12)

    Martin caught the error - my thanks to him.· All channels are working normally now·- when I reload or boot up the first ADC reading is junk, but after that all readings are right on.· Also, the unmodified ouput of the ADC is about what I get with the Stamp.

    One of my problems is that I may write in SPIN but I think in PBasic.· The incorrect structure would be correct for the Stamp, but it doesn't work that way with the bs.shiftout.· Oh, well....live and learn.

    Now to clean up the program and press on.· Thanks for all your help, Tracy.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Yesterday is history, tomorrow is a mystery, and today is a gift.

    That is why they call it the present.

    Don't have VGA?
    Newzed@aol.com
    ·
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2007-08-23 12:26
    Sorry about the structure issue Sid, yes, I should have made them compatible, and I guess it was an oversight on my part. Glad it's working.
    -Martin

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    StampPlot - GUI and Plotting Software
    Southern Illinois University Carbondale, Electronic Systems Technologies
  • JonathanJonathan Posts: 1,023
    edited 2007-08-23 15:59
    Sid,

    Just got home to the computer with the BS2_Functions/TLC2543 snip, but I see you have it working. Guess I'm a day laye and a dollar short [noparse]:)[/noparse]

    Glad you got it working!

    Jonathan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
  • Tracy AllenTracy Allen Posts: 6,660
    edited 2007-08-23 17:45
    Good catch!

    Previously then, from examination of Martin's bs.shiftout code, your call to channel 0 became LSBFIRST with value 1 (1=mode MSBFIRST but in the value position) The TLC2543 took that in as MSBFIRST and would read channel 8 (because the 1 would be interpreted by the TLC2543 as channel %1000) A bs/shiftout call to any other channel was interpreted as an MSBFIRST call to channel 0. I think? I don't know if that explains the character of the strange results. But congratulations on getting it working!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • HarleyHarley Posts: 997
    edited 2007-08-24 00:30
    Sid,

    Today I ran across your 'sign-off' via an email. URL is:
    www.members.shaw.ca/grandmafaiths2/boogie.htm

    Sorry all for going off topic. I like the play on words.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Harley Shanko
  • NewzedNewzed Posts: 2,503
    edited 2007-08-24 13:23
    Tracy, the board is working quite well now.· When I built it, I made the EEPROM a 24LC512.· Had a bit of a problem getting the EEPROM to work -· I had a pullup on SCL to Vdd and the pullup on SDA went to Resn just like the Demo Board.· When it didn't work, I took a good look at the Proto Board schematic and saw that both pullups went to Vdd with no connection to Resn.· I was able to modify my board to accomplish that and now the EEPROM works fine.· I am using 34000 to 63000, which gives me 29Kb··of storage.· That should be enough.· The next address to be used is stored at 63500.· Now all I have to do is plug in my little DS1302 module and I can date/time stamp each ADC reading.· That will be the next phase.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Yesterday is history, tomorrow is a mystery, and today is a gift.

    That is why they call it the present.

    Don't have VGA?
    Newzed@aol.com
    ·
  • NewzedNewzed Posts: 2,503
    edited 2007-08-24 23:21
    Tracy, finally got the date/time stamp working and logging with the temperature.· I was burst reading the DS1302, which led to

    bs.shiftin(io, sclk, bs#lsbpre,24)

    This would be in accordance with Stamp protocol where seconds, minutes and hours are read at one time.· This won't work with the Prop because there is no way to break out the three parameters from the 24 bits.· So after spending a couple of hours trying to figure out how to get around it, I wrote:

    seconds := bs.shiftin(io, sclk, bs#lsbpre,8)
    minutes := bs.shiftin(io, sclk, bs#lsbpre,8)

    and so on.· Shifting the data in 8 bits at a time solved the problem.

    Now I can replace my Proto Board and the companion Stamp with its ADC AppMod and all the wires with my little board and its two plug-in modules.

    So.........I'll have to think of something new and exciting for my Proto Board.· Tomorrow, that is.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Yesterday is history, tomorrow is a mystery, and today is a gift.

    That is why they call it the present.

    Don't have VGA?
    Newzed@aol.com
    ·
Sign In or Register to comment.