Shop OBEX P1 Docs P2 Docs Learn Events
Expert coder needed - Page 4 — Parallax Forums

Expert coder needed

1246

Comments

  • computer guycomputer guy Posts: 1,113
    edited 2008-02-12 06:40
    True.
    I should have the matchport by mid next week.

    Look forward to the challenge. smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out my robot using the propeller RECONAUTOR
    If you like my avatar then check this out Propeller Domed Sticker
  • computer guycomputer guy Posts: 1,113
    edited 2008-02-12 10:22
    In order to get the VB program to read in the NumScheduleItems I had to add the following line to make the following change.

    PUB sendDataSerial|i,time,[b]data[/b]
      [b]data := (NumScheduleItems/10)<<4+NumScheduleItems//10[/b]
      ser.tx([b]data[/b])'So that you know how many items there are
    
    



    I have changed the code their back to the original code.

      repeat i from 0 to NumScheduleItems-1
        time:=schedule[i]
        ser.tx(time.byte[noparse][[/noparse] 0])
        ser.tx(time.byte[noparse][[/noparse] 1])
        ser.tx(time.byte[noparse][[/noparse] 2])
        ser.tx(time.byte[noparse][[/noparse] 3])
    [/i]
    



    However I am still having trouble reading in the data properly.

    Just thought I would keep you posted. smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out my robot using the propeller RECONAUTOR
    If you like my avatar then check this out Propeller Domed Sticker

    Post Edited (computer guy) : 2/12/2008 11:06:16 AM GMT
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-02-12 10:28
    That would be because not all the numbers are stored as BCD. Only the hours and minutes are stored in BCD because that is the way the come out of the RTC.

    Just noticed you need to change this
    PUB checkSerial|temp
      temp:=ser.rxCheck
      case temp
        sendSchedule:
          sendDataSerial
        recieveItem:
          getItemSerial
        clearList:
          NumScheduleItems:=0
    



    to
    PUB checkSerial|temp
      temp:=ser.rxCheck
      case temp
        sendSchedule:
          sendDataSerial
        recieveItem:
          getItemSerial
        clearList:
          NumScheduleItems:=0
          eeprom.VarBackup(@NumScheduleItems,@NumScheduleItems+1)
    



    I wasn't writing the fact that the memory had been cleared back to the eeprom smile.gif

    This is what I get when I don't figure out exactly what has to be done first. So the moral to the story is to always figure out exactly what needs to be done and how you are going to do it before you start coding. smile.gif
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-02-12 10:30
    Didn't see your edit. To make the forum accept it just put a space after the opening bracket like this [noparse][[/noparse] 0]. Whats the trouble with reading in the data?
  • computer guycomputer guy Posts: 1,113
    edited 2008-02-12 11:37
    Am still having problems with the receiving of data.

    The data received displayed as a string in a text box is.

    0001
    0001
    1001
    0101
    
    



    This is for 4 schedules.

    Thank you smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out my robot using the propeller RECONAUTOR
    If you like my avatar then check this out Propeller Domed Sticker
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-02-12 11:43
    so
    schedule 1 - Sunday, 0 hours, 0 minutes (0:00 am), instruction code 1
    schedule 2 - same
    schedule 3 - Monday - then same
    schedule 4 - Sunday, 1 hours, 0 minutes (1:00 am), instruction code 1

    Is this what you get on the TV screen?
  • computer guycomputer guy Posts: 1,113
    edited 2008-02-12 11:45
    I get

    00:00 Sunday 01
    01:00 Sunday 01
    01:00 Sunday 02
    01:00 Monday 02

    if I send 's' and read in the data again I get

    0001
    0101
    0102
    1102
    
    



    then again

    0001
    0001
    1001
    0101
    
    



    then

    0001
    0001
    1010
    1021
    
    



    Thank you smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out my robot using the propeller RECONAUTOR
    If you like my avatar then check this out Propeller Domed Sticker

    Post Edited (computer guy) : 2/12/2008 11:53:01 AM GMT
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-02-12 11:50
    Do you get the same thing if you send the strings and use hyperterminal?
  • computer guycomputer guy Posts: 1,113
    edited 2008-02-12 11:51
    Sending the strings I get exactly what is displayed on the tv.

    Check out the previous post, I have edited it. smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out my robot using the propeller RECONAUTOR
    If you like my avatar then check this out Propeller Domed Sticker
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-02-12 11:55
    So the first time it sends the data it gets it right and then something goes wrong. Can you post the code that you are using?
  • computer guycomputer guy Posts: 1,113
    edited 2008-02-12 11:57
    VB
    
    SerialPort1.Write("s")
                SerialPort1.Read(NumSchedules, 0, 1)
                Label1.Text = NumSchedules(0).ToString
                For i = 0 To NumSchedules(0).ToString - 1
                    SerialPort1.Read(Data, 0, 4)
                    RichTextBox1.Text += Data(0).ToString
                    RichTextBox1.Text += Data(1).ToString
                    RichTextBox1.Text += Data(2).ToString
                    RichTextBox1.Text += Data(3).ToString
                    RichTextBox1.Text += vbCrLf
                Next
    
    



    Thank you smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out my robot using the propeller RECONAUTOR
    If you like my avatar then check this out Propeller Domed Sticker
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-02-12 11:59
    Sorry, I meant the spin code.
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-02-12 12:02
    Do you need to set the port speed somewhere? Also, what start/end bit settings are you using? That could be causing the problem although I would have thought that it wouldn't work at all if that was the case.
  • computer guycomputer guy Posts: 1,113
    edited 2008-02-12 12:05
    It works with sending a new schedule so that isn't a problem.

    PUB sendDataSerial|i,time,data
      data := (NumScheduleItems/10)<<4+NumScheduleItems//10
      ser.tx(data)'So that you know how many items there are
      repeat i from 0 to NumScheduleItems-1
        time:=schedule[i]
        ser.tx(time.byte[noparse][[/noparse] 0])
        ser.tx((time.byte[noparse][[/noparse] 1]/10)<<4+time.byte[noparse][[/noparse] 1]//10)
        ser.tx((time.byte[noparse][[/noparse] 2]/10)<<4+time.byte[noparse][[/noparse] 2]//10)
        ser.tx(time.byte[noparse][[/noparse] 3])
    [/i]
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out my robot using the propeller RECONAUTOR
    If you like my avatar then check this out Propeller Domed Sticker

    Post Edited (computer guy) : 2/12/2008 8:05:59 PM GMT
  • computer guycomputer guy Posts: 1,113
    edited 2008-02-12 12:06
    Will continue this tomorrow.
    It is getting late for me. smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out my robot using the propeller RECONAUTOR
    If you like my avatar then check this out Propeller Domed Sticker
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-02-12 12:07
    If the forum didn't eat the brackets it should be this
    PUB sendDataSerial|i,time,data
      data := (NumScheduleItems/10)<<4+NumScheduleItems//10
      ser.tx(data)'So that you know how many items there are
      repeat i from 0 to NumScheduleItems-1
        time:=schedule
        ser.tx(time.byte[noparse][[/noparse] 0])
        ser.tx((time.byte[noparse][[/noparse] 1]/10)<<4+time.byte[noparse][[/noparse] 1]//10)
        ser.tx((time.byte[noparse][[/noparse] 2]/10)<<4+time.byte[noparse][[/noparse] 2]//10)
        ser.tx(time.byte[noparse][[/noparse] 3])
    



    Edit: Okay, the forum is eating the brackets so it should be like this which I think is what you've got
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-02-12 12:09
    Talk to you tomorrow smile.gif
  • computer guycomputer guy Posts: 1,113
    edited 2008-02-12 20:02
    Yep that's what I have.

    When I receive each byte I store it in a byte array then use the .ToString command to convert it to a string for displaying it in the textbox.

    Thank you smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out my robot using the propeller RECONAUTOR
    If you like my avatar then check this out Propeller Domed Sticker
  • computer guycomputer guy Posts: 1,113
    edited 2008-02-12 22:42
    I have connected up my RTC.
    and modified the code to get the time from the RTC.
    I also added this line

    printTime(currentTime)
    
    



    except it prints
    Time 55:55, Day , Code 00
    
    



    Why would this be.

    I have tried to set the time just after config of the RTC using this
    clock.setDatetime( 02, 13, 2008, 03, 09, 37, 00 )
    
    


    witch corresponds with this
    setDatetime( mth, day, year, dow, hr, xmin, xsec )
    
    



    Thank you smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out my robot using the propeller RECONAUTOR
    If you like my avatar then check this out Propeller Domed Sticker
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-02-12 22:59
    Try using all numbers less than 10. Also try putting a "waitcnt(cnt)" between where you set the time and read the time.
  • computer guycomputer guy Posts: 1,113
    edited 2008-02-12 23:01
    Thank you,
    I worked it out. I am using a prototyping board and a pin got pushed up so it wasn't making contact.
    I am loosing the hour now. Am sure it is something simple though.

    Thank you smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out my robot using the propeller RECONAUTOR
    If you like my avatar then check this out Propeller Domed Sticker
  • computer guycomputer guy Posts: 1,113
    edited 2008-02-12 23:03
    Could have something to do with having no battery backup connected to the RTC. smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out my robot using the propeller RECONAUTOR
    If you like my avatar then check this out Propeller Domed Sticker
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-02-12 23:07
    Thats probable my fault. I think it is setting up the clock for 12 hours and not 24. change this
    [code]
    PUB config
    write($90,$a6) ' Init chargeing register 1010 0110 charge activ
  • computer guycomputer guy Posts: 1,113
    edited 2008-02-12 23:39
    Ok Thank you,
    Will try that.
    I ran a test and all works well.
    Just one thing. I might be getting fussy but would it be possible to get the do instruction to only execute if not already running.

    Like
    PUB doInstruction(instruction)
      'This will turn on/off whatever pin or do whatever else we want to do
      'Could even hoopup one of the timers so that we could get a PWM output
      case instruction
        start1:
          [b]if start1 := false[/b]
            outa[noparse][[/noparse]pin1]~
            text.str(string(13,"called code start1"))
        stop1:
           [b]if start1 := true[/b]
             outa~~
             text.str(string(13,"called code stop1"))
    
    



    Thank you smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out my robot using the propeller RECONAUTOR
    If you like my avatar then check this out Propeller Domed Sticker
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-02-12 23:49
    Yes you could but you would need an extra variable like this
    VAR byte start1Running
    PUB doInstruction(instruction)
      'This will turn on/off whatever pin or do whatever else we want to do
      'Could even hoopup one of the timers so that we could get a PWM output
      case instruction
        start1:
          if start1Running == false
           start1Running==true
            outa[noparse][[/noparse]pin1]~
            text.str(string(13,"called code start1"))
        stop1:
           if start1Running == true
             start1Running:=false
             outa~~
             text.str(string(13,"called code stop1"))
    


    Just make sure that you change the ':=' to '==' in the if statements. smile.gif I often make that mistake. Are you still having problems with the serial?

    I love the resizable text input boxes in Safari, makes it much easier to type in code when you can see all of it

    Ok I'll stop being a mac fanboy smile.gif
  • computer guycomputer guy Posts: 1,113
    edited 2008-02-13 00:02
    Thank you smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out my robot using the propeller RECONAUTOR
    If you like my avatar then check this out Propeller Domed Sticker
  • computer guycomputer guy Posts: 1,113
    edited 2008-02-13 00:44
    When I power up the propeller there is always the following schedules in there even after I have just done a clear.

    Time 00:00, Day Sunday, Code 00
    Time 00:00, Day , Code 00
    
    



    I can override them and all is fine.
    How can I make it so that clear really does clear.

    Thank you smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out my robot using the propeller RECONAUTOR
    If you like my avatar then check this out Propeller Domed Sticker
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-02-13 00:48
    That may be the two I put in at the start of the program to test with but I don't think that those were the values that I was using. If its not can you archive and post the project?
  • computer guycomputer guy Posts: 1,113
    edited 2008-02-13 00:51
    I have commented out those two.
    Here is the code I have.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out my robot using the propeller RECONAUTOR
    If you like my avatar then check this out Propeller Domed Sticker

    Post Edited (computer guy) : 2/13/2008 12:56:43 AM GMT
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-02-13 01:19
    Its now fixed. It was a problem with the loops. When the number of items was 0 it was trying to do
    repeat i from 0 to numScheduleItems-1

    so it was looping from 0 to -1 instead of not doing anything smile.gif

    now it does

    i:=0
    repeat while i<numScheduleItems
    



    which works much better smile.gif

    You'll have to change the constants back and I added another constant for the TV pin
Sign In or Register to comment.