BS-2pe OUTPUT PORT GLITCH
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.
·
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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
-Phil
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
Thanks for suggestions.
I am going to try it immidiatelly.
Regards,
student01