Shop OBEX P1 Docs P2 Docs Learn Events
BS-2pe OUTPUT PORT GLITCH — Parallax Forums

BS-2pe OUTPUT PORT GLITCH

student01student01 Posts: 3
edited 2009-12-27 03:32 in BASIC Stamp
Hi guys,
Please help me to identify the problem.
I am working with BASIC Stamp 2pe Motherboard.
The MoBoStamp-pe includes a USB interface with attached PC.

In my project 4 output ports are used to control periferial devices directly (without any additional register or buffer IC).
Visual Basic application sends command numbers from 1 to 9 to the BASIC Stamp 2pe Motherboard.
One of those commands turns ON the power on the periferial device, another - defines the power supply voltage.
It is like a programmable power supply.

My goal is to make it work like this:
When PC sends enother number, the Basic Stamp receives and idetifies the number as command and than performs the
subrutine accodingly without interrupting the behavior of the latched outputs.

I have a critical problem:
Each time the number is sent from PC a glitch apears on the BASIC Stamp output ports.
This is unacceptable for the application.
This glitch, I suspect, caused by the BASIC Stamp program· jump to the beginning of the code.
To test this I inserted the "PAUSE 500" line at the top of the code and connected LEDs to the outputs through the
resistors.
Each time PC sends the number to the BASIC Stamp it produces a glitch which duration depends on PAUSE value.
I expected that BASIC Stamp ports configured as outputs will behave as latched ones.

LEDs blink on the command from PC even if I leave only this portion of the code:
Main: '
··· SERIN $16, $4054,[noparse][[/noparse] FromPC] 'Get number from PC
END


The folowing VB6 code used to send the number from the PC to the BASIC Stamp:
a = 1 ' 1 is a number sent
MSComm1.Output = a


The PBASIC code for the BASIC Stamp is:
'{$STAMP BS2pe}
' {$PBASIC 2.5}
'
[noparse][[/noparse] Variables ]
FromPC VAR Byte 'To store the data from PC
'
[noparse][[/noparse] Initialization ]
OUTPUT 2 'Configure port as output
OUTPUT 3 'Configure port as output
Main: '
··· DO
··· SERIN $16, $4054,[noparse][[/noparse] FromPC] 'Get number from PC
····· IF···· FromPC = "1"·· THEN
······· GOSUB 1'...
····· ELSEIF FromPC = "2"·· THEN
······· GOSUB 2'...
····· ELSEIF FromPC = "3"·· THEN
······· GOSUB 3'...
····· ELSEIF FromPC = "4"·· THEN
······· GOSUB 4'...
····· ENDIF
··· LOOP
END
'
[noparse][[/noparse] Subroutines ]
1: 'Port2 -ON
·· HIGH 2
RETURN
2: 'Port2 -OFF
· LOW 2
RETURN
3: 'Port3 -ON
· HIGH 3
RETURN
4: 'Port3 -OFF
· LOW 3
RETURN

I spent a LOOOOOT of time trying to solve this problem.
Any advice would be greatly appreciated.
·

Comments

  • FranklinFranklin Posts: 4,747
    edited 2009-12-27 02:07
    Start by getting the number from the PC and then displaying it from the stamp with debug. I think you will find what you are receiving is not what you are expecting.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-12-27 03:11
    Shouldn't the argument to MSComm1.Output be a string, instead of an integer? And why are you using inverted polarity for SERIN? Also SERIN $16 is not the same as SERIN 16 — the latter being the proper way to read input from the PC.

    -Phil
  • student01student01 Posts: 3
    edited 2009-12-27 03:26
    Hi Stephen,

    thanks for the fast responce.

    I can't use the PC communication port and debug window at the same time.

    Pc tellse me the Port is busy.

    Is there any way to assign specific port number for the debug window, or separate send-receive ports somehow?

    Thanks,

    student01
  • student01student01 Posts: 3
    edited 2009-12-27 03:32
    Hi Phil,
    Thanks for suggestions.
    I am going to try it immidiatelly.
    Regards,
    student01
Sign In or Register to comment.