Shop OBEX P1 Docs P2 Docs Learn Events
Using multiple VPs — Parallax Forums

Using multiple VPs

johnatworkjohnatwork Posts: 7
edited 2006-05-02 15:16 in General Discussion
Hello!

I am participating in a project where me and my team are building an implementation for the Boe-Bot (using Javelin)

The bot is supposed to be heavily equiped with serveral hardware modules.
After doing some research we realized that a lot of these modules require VPs to be running in the background. We've estimated the amount of VPs and they seem to exeed the maximum that can be used concurrently (in Javelin)

The module and estimated VPs are:

* 1 Bluetooth module (2 VPs)
* 2 Servos (1 VP each)
* 4 Infrared kits (2 VP each)
* 2 PING)) Ultrasonic range finder (No VPs)
* 1 CMUCam camera (2 VPs)

Our proposed solution is to simply turn of (or uninstall) the VPs when they are not needed, however this can only be done with a few modules, for example the Servos and Bluetooth receiver needs to be running at all times, whereas the IR-kits and Bluetooth sender can (supposebly) be turned off when not used.

The questions are:
* Is it feasible to do as mentioned above (turn on and off when needed)?
* If so, is there any time-factor involved in doing that?
* Is is possible to use the IR-sensors without PWMs and DACs ? (I am using the code from the JBot project)

Sincerely,

John.

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-05-02 08:53
    I always reserve 1 vp for the timers (can't really do without timers can you)
    Then I use 1 vp for all uart transmit, only starting the one you need
    Also, uart receive with handshake can be turned off, as can uart receive
    that are used in half duplex where a uart transmit is in control.

    So the vp constantly in use are:
    1x timers
    2x pwm (servos)
    1x uart/pwm transmit (for Bluetooth transmit, cmucam transmit, IR transmit)

    That leaves 2 vp for IR receive, what IR kit do you use?
    Also, the Bluetooth receive, will the javelin receive data at random
    or only after javelin sends command? Any hardware handshake available?

    regards peter
  • johnatworkjohnatwork Posts: 7
    edited 2006-05-02 09:55
    Hello Peter,

    Thanks for the quick reply, I did forget to mention the timer... Yes we will be using one timer.

    So you're saying that we should be sharing one UART for all transmitting? I guess that is do-able.
    However the code for the IR-sensors, we're using those that come with the Boe-Bot (Rev B, USB), does not use a UART, it uses one PWM and one DAC. (Maybe we should switch to using a UART in order to share it between devices)

    I suppose you're using the restart method in the UART class for changing the I/O-pins when sharing the UART between serveral hardware devices? How long does it take to restart to UART?

    About sharing the VPs (PWM, DAC and UART), does calling stop() actually remove the VP from the slot? Or does Javelin keep track of which slotted-VPs are stopped and automatically swap them out when needed?

    The Bluetooth receives data aperiodically, so the reciever has to be running constantly.

    /John
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-05-02 10:42
    When a vp is stopped, it is actually uninstalled from the vp list, the definition
    for a vp (eg. a uart definition) remains intact, so it can be started again later.
    (It then will start in the first available vp slot)

    You say your IR sensor uses pwm and dac (which is a special pwm), so these
    are used only for transmit, where photoresistors are used to receive the IR signal,
    as in the attached file (from JBot application). Only 2 vp's are active at a time (method getRange).
    Or am I incorrect about this?

    You may define as many vp's as you need. Only 6 can be active simultaneously.

    always active:
    1x timer
    1x uart receive (Bluetooth)
    2x pwm (servos)

    started/stopped when required:
    1x uart transmit (Bluetooth,cmucam) / pwm (IR)
    1x uart receive (cmucam)·/ dac (IR)

    The above is doable, unless the cmucam sends data without being polled for it.

    You could decide to use the PSC board (half duplex serial I/O)
    for controlling up to 16 servos. That would free up two vp slots.


    regards peter


    Post Edited (Peter Verkaik) : 5/2/2006 10:52:43 AM GMT
  • johnatworkjohnatwork Posts: 7
    edited 2006-05-02 11:16
    Actually, I am using that exact attached code for the IR-sensors, so it will work out fine.

    We might also implement Accelerometers to count ticks for each wheel. We've come to the conclusion that we need to run a task (perhaps one for both accelerometers) that keeps counting. I suppose that the task requires an additional VP? or can it be shared with, say, the timer VP?

    The PSC board sounds interesting, I will look into that.

    /John
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-05-02 11:27
    The code I have seen for accelerometers (like memsic 2125) uses
    the pulseIn() method, so no vp is required for that.

    Tasks are usually implemented using timeslices. You can have as many timers
    as you want because·only 1 vp slot is used for all timers.

    regards peter
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-05-02 11:38
    I think you are short of I/O pins.

    Bluetooth receive·· 1 pin
    Bluetooth transmit· 1 pin
    IR pwm··············· ·4 pins
    IR dac················ ·4 pins
    photoresistors······ ·4 pins·
    cmucam receive···· 1 pin
    cmucam transmit··· 1 pin
    servos················· 2 pins
    ping·····················2 pins

    Gives a total of 20 pins.

    regards peter

    Post Edited (Peter Verkaik) : 5/2/2006 11:41:42 AM GMT
  • johnatworkjohnatwork Posts: 7
    edited 2006-05-02 14:48
    Hello again,

    I managed to get the IRs working with only two pins using (almost) the exact same code as you attached. It seems to work pretty good... I get linear value, smaller when holding my hand closer and bigger when further away.

    Also doesn't the accelerometer take 1 pin each?

    Is it possible for serveral devices to share the same pin? For example, two IRs sharing the same pin as they are never used at the same time?

    I noticed that there are serveral PIN-rows that share the same numbers(P1, P2, etc), however they are labeled X1 to X5

    The question is: Are there only 16 exclusive pins available?

    /John

    Edit: 16 not 15 exclusive pins

    Post Edited (johnatwork) : 5/2/2006 3:14:33 PM GMT
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-05-02 15:16
    The javelin has 16 I/O pins, CPU.pin0 to CPU.pin15
    I think you can drive multiple IR leds simultaneously, but it all depends
    on how much current is drawn. Each pin can only sink/source 25mA
    and each group of 8 pins (portA and portB) can handle 50mA.

    Each·axis of an accelator uses 1 pin. The memsic2125·has 2 axes·and
    uses 2 pins.

    regards peter

    ·
Sign In or Register to comment.