Shop OBEX P1 Docs P2 Docs Learn Events
Calling the same object multiple times — Parallax Forums

Calling the same object multiple times

Earl FosterEarl Foster Posts: 185
edited 2008-07-08 00:52 in Propeller 1
I am calling the FullDuplexSerialPlus.SPIN object·3 times in my program to communicate·with the·3 seperate serial devices listed here.

1. Serial Terminal Debug
2. Serial GPS
3. Serial USB Drive

I know the compiler only compiles one instance of the object but am I using·3 additional COGs in my program since fullduplexserialplus.spin requires a new COG?


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
WWW.HAPB.NET

"Don't ask yourself what the world needs - ask yourself what makes you come alive, and then go do it." - H.T.Whitman

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2008-07-07 20:55
    Yes you will be starting a new cog each time you call the start method.

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

    Parallax, Inc.
  • edited 2008-07-07 21:56
    You can probably save some code space by using FullDuplexSerial (in the Propeller Tool's Library folder) for communication with the with the USB drive.

    If the Serial GPS and Debug Terminal don't need to talk at the same time, you can use the Propeller Tool's Simple_Serial library. Whatever cog calls its method ends up doing the serial communication. No new cogs, but don't go over 19.2 Kb/s.

    An alternate approach would be to call one FullDuplexSerial (or ...Plus) object's start method to successively reconfigure it. The start method stops the cog if it's running and then launches with the new settings. Your application code may have to do a little footwork to make sure the FullDuplexSerial object's Start method doesn't get called in the middle of sending or receiving bytes, and it might also be necessary to set pin states from the cog that calls the FullDuplexSerialPlus methods so that they don't float when the FullDuplexSerial cog lets go of them when it moves on to another set of pins.

    Some notes regarding versions: Get the Propeller Tool v1.2 for the latest Simple_Serial object. If you continue to use FullDuplexSerialPlus, make sure to use version 1.1, which is available from the Objects Lab, v1.1 or newer.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andy Lindsay

    Education Department
    Parallax, Inc.

    Post Edited (Andy Lindsay (Parallax)) : 7/7/2008 10:15:14 PM GMT
  • TimmooreTimmoore Posts: 1,031
    edited 2008-07-07 22:08
    The other thing to look at is http://forums.parallax.com/forums/default.aspx?tabid=&f=25&m=273291, it supports up to 4 serial ports with 1 cog. Its not on Prop Object exchange yet but it will be when I have a bit of time.
  • Earl FosterEarl Foster Posts: 185
    edited 2008-07-08 00:52
    Great, Thank you

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    WWW.HAPB.NET

    "Don't ask yourself what the world needs - ask yourself what makes you come alive, and then go do it." - H.T.Whitman
Sign In or Register to comment.