Shop OBEX P1 Docs P2 Docs Learn Events
General Coding Questions — Parallax Forums

General Coding Questions

rcm14rcm14 Posts: 11
edited 2012-04-12 06:31 in Propeller 1
For my project, I am using the Full Duplex Serial object for three aspects: 1) control an LCD, 2) control a line-of-sight infrared emitter/receiver pair, and 3) pass information to and from the computer screen. This is using 3 separate cogs, and (including these 3) am using all of the Propeller's 8 cogs. Is there anyway to consolidate the Full Duplex Serial so I'm not using so much space?

Also, I have had some trouble getting my 8th cog to start. I've scanned my code over and over and have only counted 8 cogs including cog 0 which is used to call the objects which contain the other cog calls. As of now my code is split into 3 sections: 1) Top Level File to control the setup of my system, 2) an LCD file to control my LCD operations, and 3) a serial communication file for the operation of the emitter/receiver pair. Again, is there anything I can do with my code to maybe help consolidate some space and possibly avoid problems with my cogs not starting?

Thank you for any help.

Comments

  • turbosupraturbosupra Posts: 1,088
    edited 2012-04-11 21:07
    Are you counting PUB Main, which uses cog 0, or are you using another cog to manage cog calls?

    Also, what type of timing updates/requirements do you need for the 3 full duplex serial cogs? I've never had the need to use more than 1 full duplex serial object and I'm not a very efficient coder.

    Can you post your code to give us a better understand of what you are dealing with? You can go into File --> Archive --> Project and create a compressed file of your project and upload it/attach it to a forum post.
  • rcm14rcm14 Posts: 11
    edited 2012-04-11 21:25
    I am counting PUB Main as cog 0.

    I thought I would need three separate full duplex serial cogs since I had 3 separate tx/rx pin combinations that I needed to manage. But then again, that's why I'm asking this question.

    I tried to upload an archived version, but for some reason the attachment manager couldn't find the file. Sorry. LaserTag.spin is the top file, and the other two are the main two objects other than the Full Duplex Serial.

    gun_vest.spin
    gunLCD.spin
    LaserTag.spin
  • Mike GreenMike Green Posts: 23,101
    edited 2012-04-11 21:34
    There is an object in the ObEx that provides up to 4 serial ports using just a single cog. It's lately gone through some revisions in this forum. You might look at the object and look back through the last week or so of Propeller forum threads.
  • rcm14rcm14 Posts: 11
    edited 2012-04-11 22:10
    I do have one more quick question to add. For the "repeat while/until" type commands, when does the loop actually terminate once the condition is met?

    For instance, here is some code:
    PUB Main[INDENT]dira[0]~
    dira[1]~~
    repeat while ina[0] == 1[/INDENT]
    [INDENT=2]!outa[1]
    waitcnt(clkfreq + cnt)[/INDENT]
    

    Let's say pin[0] is equal to 1, and the code is currently executing the waitcnt() command. Then while still executing the waitcnt() command, pin[0] goes to 0. Will the waitcnt() command finish before the repeat loop terminates?
  • JLockeJLocke Posts: 354
    edited 2012-04-11 22:31
    I believe this is the object you're looking for; see post #10 in the thread. I've just implemented it into a project using 2 ports, and it's working well so far.

    http://forums.parallax.com/showthread.php?137349-yet-another-variant-fullDuplexSerial4portplus
  • rcm14rcm14 Posts: 11
    edited 2012-04-11 23:27
    Awesome! Thank you all for the help!
  • kuronekokuroneko Posts: 3,623
    edited 2012-04-11 23:32
    rcm14 wrote: »
    Let's say pin[0] is equal to 1, and the code is currently executing the waitcnt() command. Then while still executing the waitcnt() command, pin[0] goes to 0. Will the waitcnt() command finish before the repeat loop terminates?
    waitcnt runs to completion. Only then (i.e. after about a sec) is the exit condition checked again. IOW, if you set a rather long delay said pin can change several times without having an effect.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-04-12 06:31
    rcm14 wrote: »
    I tried to upload an archived version, but for some reason the attachment manager couldn't find the file.

    Windows 7 doesn't like programs using the "Program Files" folder to store data. The OS then "hides" these data files (at least it seems like hiding to me) in the "VirtualStore".

    On my computer, files often end up in "C:\Users\Duane\AppData\Local\VirtualStore\Program Files (x86)\Parallax Inc\".
Sign In or Register to comment.