Shop OBEX P1 Docs P2 Docs Learn Events
Need help setting up a New Cog for method. — Parallax Forums

Need help setting up a New Cog for method.

JMLStamp2pJMLStamp2p Posts: 259
edited 2008-03-10 13:01 in Propeller 1
Please see attached "Spin" file.
This·is a working code model and is well documented.

I would like to have my "Recieved_Data" method running in a new cog by itself.
The reason for this is because I am sending data back and forth between two Props via an "RF" link. The Data being sent is first entered by a Keypad and therefore the need for Entering data and recieving at the same time is nessessary. I have tried going over the examples in the Prop manual and running them but wen I compile the code the LCD does not work properly.
Need an example code fragment to accomplish this.
Thanks,
JMLStamp2p

Comments

  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-03-07 23:21
    Is this working now?
  • Paul BakerPaul Baker Posts: 6,351
    edited 2008-03-08 00:25
    Hi John, I finally have some time to look at your question. Was this the thread you asked for my assistance in or the other one related to method coding? If I don't get a response before I leave the office today, I'll take a look at it over the weekend.

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

    Parallax, Inc.
  • JMLStamp2pJMLStamp2p Posts: 259
    edited 2008-03-08 12:00
    Hello Paul this is the one.
    stevenmess, Thank You for your help !
    The Spin file attached is working properly, the only thing that I really need help on is to have my "rxStr" method running in a seperate Cog. I my notes above I had said that Reiceved_Data
    method needed this. I remembered a post from Mike Green and decided that I should probally leave Cog "0" running in an endless loop at the bottom of "Main" code and run rxStr in a seperate Cog instead.
    The reason for this is that I need to recieve data through the Tranceiver and use the Keypad at the same time.
    Thanks for your help guys, this project is very Important as it is a pilot project to use Parallax
    devices in our Plant. We usually spend around $2,000.00 a month on "Small" electronic devices
    for buget purposes :>)
    Thanks,
    JMLStamp2p
  • JMLStamp2pJMLStamp2p Posts: 259
    edited 2008-03-08 12:02
    I have tried following the examples but must be doing something wrong. Every time I try running "rxStr" in a seperate Cog my LCD starts acting Crazy.
    Thanks,
    JMLStamp2p
  • JMLStamp2pJMLStamp2p Posts: 259
    edited 2008-03-08 14:32
    Hello, I have listed "Mains" code here as to how I need the Logical flow of the program to run. Please let me know if you think the flow is correct. See comment at the bottom and Thank You all for your help.
    JMLStamp2p




    PUB Main : Success | Value

    '

    ' Set up Communications in different Ports and Initialize LCD.

    '

    data.Stop
    data.start(1,0,%0010,9600)
    'Set up new Cog "#1" to handle Tranceiver calls.

    data_LCD.Stop
    data_LCD.start(3,2,0,19200)
    'Set up new Cog "#2" to handle LCD calls.

    LCD_Setup
    'Set up the default display screen for the LCD, via Cog "0".

    '

    'Process Initial Value of "Global Timer varibles via Keypad input.
    'Show them on the LCD, Transmit them to the Remote Prop and then wiat
    'for Recieved Data for "Global Timer varible change".

    '

    rxStr(9,@datain)
    'Get 3 sets of "3 digit" numbers from the Keypad, via Cog "0".
    'Means the Program is haulting for input here.

    Handle_Number_1(@datain)
    Handle_Number_2(@datain)
    Handle_Number_3(@datain)
    'Do number conversion for "Global" Timer varibles, via Cog "0".

    Print_Status_to_LCD
    'Print "Global" Timer varibles to the LCD via Cog "0".

    Transmit_Timer_values(@datain)
    'Transmit Numbers entered via Keypad out the Port to the Remote Prop.

    repeat

    Recieved_Data(9,@datain)
    'Wait for more Received Data which is a new Value for the Global Timer
    'varibles, writes them to the "datain" Array.

    Print_Status_to_LCD

    'NOTE: At this point in the program I need to have access to input
    'another set of numbers via the Keypad to Transmit back to the Remote
    'Prop. Since Cog "0" is in a repeat loop here I assume that I need to
    'have rxStr running in a seperate Process.
    'Need help via example code.
  • JMLStamp2pJMLStamp2p Posts: 259
    edited 2008-03-08 16:48
    NOTE:

    The following code is running in the receiver Prop. I can send 3 sets of 3 digit numbers from the tranmitter and it will show up perfect every time on the receive end. When I try and adjust this code to to use rxStr "see attached file" The receiver props LCD will show the first digit that I·had sent·and the rest will be "0's".

    JMLStamp2p

    PUB Main

    ·data.Stop·············
    ·data.start(1,0,%0010,9600)

    ·data_LCD.Stop
    ·data_LCD.start(3,2,0,19200)

    ·LCD_Setup·
    ·Recieved_Data(9, @datain)
    ·Print_Status_to_LCD
    ·Main
  • JMLStamp2pJMLStamp2p Posts: 259
    edited 2008-03-08 16:56
    The only methods that I am trying to incorperate that uses the array "datain" is rxStr
    & Print_Status_to_LCD. The latter just reads and writes the array bytes to the LCD. I am suspicious that the problem may be in my rxStr Method coding. I'm going over and over it ...

    JMLStamp2p
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-03-09 04:12
    In your post above you are recursively calling Main. This is very bad as you will use up all the stack space and than bad things will happen. Also, as in the other thread you will need to set the pin directions in the new cog.

    Edit: this is for the recieve cde.

    Also, this code
    if char == (70)                                                                
          'char := "D"                                
           Main
    
    


    Is calling main which could be a problem.

    I think there may be more but this is a start.

    Post Edited (stevenmess2004) : 3/9/2008 4:20:51 AM GMT
  • JMLStamp2pJMLStamp2p Posts: 259
    edited 2008-03-09 13:51
    stevenmess,
    Thank You for your advice and examples, they are always helpful to me. Would you please take a look at my latest post, it is to the forum adminastrators attention but was not meant to be exclussively to him. It has my complete Transmitter and Receiver code posted in two seperate files with complete comments and should be easier to understand.

    Thanks so much for your help, it is appreciated more than you know !
    JMLStamp2p

    PS: How do you install your replys in the grayed out box with Blue text as above ?
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-03-09 21:40
    Put a [noparse][[/noparse] code ] and [noparse][[/noparse] /code ] (without the spaces) around the bits you want in the box. smile.gif If you use Post Reply one of the buttons will do this for you.
  • JMLStamp2pJMLStamp2p Posts: 259
    edited 2008-03-10 13:01
    Thank You stevenmess,
    JMLStamp2p
Sign In or Register to comment.