Shop OBEX P1 Docs P2 Docs Learn Events
Is there a serial driver that dosn't take up a cog? — Parallax Forums

Is there a serial driver that dosn't take up a cog?

Matthew HMatthew H Posts: 23
edited 2009-08-17 20:25 in Propeller 1
I've been trying to free up some of my cogs to make room for advancement's I'm planing on one of my projects and I've started wondering if there is a way I can send serial data back to my PC for debugging without taking up a cog by using Simple or FullDuplex Serial.

Sorry if this sounds vague and you need some more details to help me, but it just seams like a simple question.

-Matthew

Comments

  • T ChapT Chap Posts: 4,223
    edited 2009-08-15 02:01
    Look at the 4port in the exchange, then one cog will run 4 serial ports.
  • TimmooreTimmoore Posts: 1,031
    edited 2009-08-15 02:03
    I can think of 2 options
    1. Simple_serial doesn't use a cog
    2. the is a 4 port serial object so if you use a serial prot elsewhere you can change it to use the 4 port versiona and use the same cog for debug.
  • Matthew HMatthew H Posts: 23
    edited 2009-08-15 02:09
    I've used simple serial before but for some reason, I never realized it doesn't use a cog like FullDuplex Serial.

    Thanks for the help guys,

    -Matthew
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-08-15 07:16
    as your target is to free cogs if you tell us details about your program it might be possible that other parts of your program can share a cog too

    best regards

    Stefan
  • Matthew HMatthew H Posts: 23
    edited 2009-08-15 17:10
    Ok, here is the general idea of my program and I will attach the code. This Program is for my RC Car that is controlled by a Proto Board. I have attempted to document as I go but there are some sections that have no documentation and there are defiantly places that I should tidy up. Thanks to Timmoore's suggestion I am no longer using Full Duplex to debug which gave me the cog I need to add in a GPS sensor down the road. But if anyone can see a way reduce the number of cogs I'm using now, I would appreciate the help.


    RC_Car v3-1 Main.spin (Assesses all data and attempts to avoid obstacles) (1cog)

    ├──RC_Car-Watch v1-0.spin (Watch for errors and low battery) (1 cog)
    │ │
    │ ├──ASM ADC code (monitor battery level) (1 cog)
    │ │
    │ └──Simple_Serial.spin (Debug back to PC)

    ├──RC_Car-Scan v1-1.spin (Sweeps PING sensor back and forth on a servo to watch for obstacles) (1 cog)
    │ │
    │ ├──servo4.spin (Controls servo that PING is mounted on) (1 cog)
    │ │
    │ ├──HM55B Compass Module Asm.spin (1 cog)
    │ │
    │ └──HM55B Compass Calibration.spin

    └──RC_Car-Motors v1-2.spin (Controls the motor controller and a H-bridge to steer and drive) (1 cog)

    └──Simple_Serial.spin (Talks to the motor controller) (1 cog)

    Thanks,
    -Matthew
  • John AbshierJohn Abshier Posts: 1,116
    edited 2009-08-15 17:40
    I count seven cogs in use from your description. CarWatch could be incorporated into main. Checking the battery every second should be sufficient.

    John Abshier
  • TimmooreTimmoore Posts: 1,031
    edited 2009-08-15 17:48
    The attached files may help
    tb6612_3.spin is h-bridge driver. It doesn't use a cog but uses pwm_32_sv2.spin for pwm control which does use a cog. pwm_32_sv2.spin can also conrol servos. It will share a cog across all the uses of pwm_32_sv2.spin for all pwm and servo usage. It is a variation of beau's pwm_32_v2.spin, it can handle 32 pins as pwm or servo, the main diff from Beau's version is the shared cog.
    So you can repace your h-bridge controller and your servo controller - 2 cogs with this that uses 1 cog.
  • Matthew HMatthew H Posts: 23
    edited 2009-08-15 18:17
    @John, I was originally planning to add more error checks and such in addition to just monitoring the battery, and I wanted in to run independently in it's own cog. But I guess until I actually go that far, for now it makes more sense to just watch the battery from the main program.

    @Timmoore, wow, thanks a lot! I won't be able to start working it into my program until tomorrow or maybe even Monday, but that should really help.

    Thanks,
    -Matthew
  • TimmooreTimmoore Posts: 1,031
    edited 2009-08-15 19:03
    It looked like you are using the Pololu Micro Dual Serial Motor Controller? Looks like the commands match though I think pololu use the same controller chip for many of their controllers. I have an object using the 4port serial driver for that controller if you are interested.
  • Matthew HMatthew H Posts: 23
    edited 2009-08-16 05:05
    Yes I'm using the Pololu Micro Motor Controller. I wouldn't mind taking a look at it if you don't have to search for it to much. I don't know that I would use it though since it use the 4port serial driver since I think it use a cog and I'm using Simpler Serial which doesn't. But I might learn something from it.

    I still haven't tried working your PWM_32_sv2.spin program into my program, and thanks to my work schedule it looks like I won't have a chance to till Monday.

    Thanks,
    -Matthew
  • TimmooreTimmoore Posts: 1,031
    edited 2009-08-16 05:15
    Here it is, the mdmsc.spin handles the controller and motormdmsc.spin handles overall motor control in this case for a 3 or 4 wheel omnibot.
  • Matthew HMatthew H Posts: 23
    edited 2009-08-17 20:25
    Well, I finally got around to working PWM_32_sv2.spin into my program and it went without a hitch. After looking through it, I was able to change my RC_Car-Motors and RC_Cars-Scan objects to use PWM_32 quite easily. Thanks again Tim for showing me this object.

    This means I now have 3 cogs free, which is more than I needed to free up in the first place!

    Thanks again for the help,

    -Matthew
Sign In or Register to comment.