Shop OBEX P1 Docs P2 Docs Learn Events
DS1302-demo coding question — Parallax Forums

DS1302-demo coding question

lfreezelfreeze Posts: 174
edited 2007-08-16 20:31 in Propeller 1
Please HELP...
I have been spent some time with the propellor tutorial, and found it very helpful in learning "spin" basics.
I decided I would try working on an RTC application. I modifiied the object "DS1302-demo" to
produce an output via hyper terminal.· to my surprise it actually worked.
It produced the following display
current time is· 10:25:0
current date is 8:15:7
My question is what object and what code needs to be modified to display the leading zeros in the time and
date. I have searched the manual for a clue but was not successful. the program is attached
Also I am using a propstick, an would like to know if the 3.3v pin can be used to drive external components and
if it can, how many MA is acceptable.
Thank you in advance for any help.....

Larry

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-08-16 03:20
    For those elements you want to have a leading zero, place this snippet before sending the serial data:

    if val < 10 
      ser.tx("0")
    


    where val is the variable you are about to send (ie minute, year, etc).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • lfreezelfreeze Posts: 174
    edited 2007-08-16 17:27
    Thank you Paul, your suggestion worked perfectly. Is this type of manipulation of variables· described anywhere in the Propellor manual?

    I usually search the manual before posting but was not successful in this case.·

    Also I am using a propstick, and would like to know if the 3.3v pin can be used to drive external components and
    if it can, how many MA is acceptable.

    Larry
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-08-16 20:31
    Something like that is more of a general programming thing and is learned through experience. If you are using a PropStick USB the amount of current you can draw from the on board regulator is highly dependent on how many cogs you are running and what kind of I/O you are driving, if you are only driving light loads from your I/O pins you should be able to draw 150-200 mA from the 3.3V pin.

    If you started getting glitchy behavior when it worked before you are likely drawing too much current from it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
Sign In or Register to comment.