Remi
Midiologie.nl. Makers van LPTpushbutton. Als je echt van je hobby houd, laat dom commentaar van anderen je koud.
Beste CO'ers
verstand van VB heb ik maar geen verstand van PICBASIC
ik probeer nu picbasic te leren en wil hiermee informatie sturen naar een pc toe
wat moet deze routine doen.
ik heb gebruik gemaakt van een voorbeeld programeering uit
het programma proton en deze getracht uit tebreiden.
klopt het verhaal wat hier staat
en zal de pic zo ook informatie sturen naar mijn serieele poort als deze is aangesloten ? of moeten er voor de serieele poort nog meer gegevens worden ingezet ?
'wanneer sw1 of sw2 word ingedrukt wordt het cijfer 1 naar de serieele poort gestuurd en zal led1 of led2 aan gaan.
'wanneer sw1 en sw2 worden ingedrukt zal het cijfer 2 naar de serieele poort worden gestuurd en zal led1 en led2 aan gaan.
'wanneer de sw3 word geopend zal het cijfer 3 naar de serieele poort worden gestuurd
'wanneer de sw4 word ingedrukt gaan de leds weer uit en zal het cijfer 0 naar de computer
'worden gestuurd
'daarnaast zal bij de ingedrukte knop een led gaan brandenOPTIMISER_LEVEL = 6
SET_DEFAULTS PROTON_4Device 16F877
Dim buf1 As Byte
Dim buf2 As Byte
Dim buf3 As Byte
Dim buf4 As Byte
Dim flt As FloatSymbol sw1 = portB.4
Symbol sw2 = portB.5
Symbol sw3 = portB.6
Symbol sw4 = portB.7
Symbol led1 = portD.5
Symbol led2 = portD.6
Symbol 2led = portD.5 And portD.6delay 500
ALL_DIGITAL = True
Clear
Low portD
TRISB = %11110000
PORTB_PULLUPS = Onchk1: DelayMS 25
Button sw1,0,40,5,buf1,0,chk2
flt = 1
HRSOut DEC1 flt
Toggle led1chk2: Button sw2,0,40,5,buf2,0,chk3
flt = 1
HRSOut DEC1 flt
Toggle led2chk3: Button sw1,sw2,0,40,5,buf3,0,chk4
flt = 2
HRSOut DEC1 flt
Toggle 2ledschk4: Button sw3,1,40,5,buf4,0,chk5
flt = 3
HRSOut DEC1 flt
Toggle led1,led2chk4: Button sw4,0,40,5,buf5,0,chk1
flt = 0
HRSOut DEC1 flt
Toggle led1,led2goto chk1
en dan vraag 2
wat doet deze string ?
Button sw1,0,40,5,buf1,0,chk2
sw1 kan ik begrijpen dit is drukknop1 dan de 0 na de eerste comma kan ik mij voorstellen dat dit de huidige status van sw1 moet zijn
maar dan tot aan chk2 waat houd dat allemaal in ?
de laatste begrijp ik ook nog wel hij moet verder gaan naar chk2
wie kan mij dit allemaal iets verder toelichten ?
greets
Remi
LuckyBasterd
:D Eagle addicted!! :D
de laatste is duidelijk
controleer de helpfile maar is
BUTTON 12 14 16
Syntax
BUTTON Pin , DownState , Delay , Rate , Workspace , TargetState , Label
Overview
Debounce button input, perform auto-repeat, and branch to
address if button is in target state. Button circuits may
be active-low or active-high.
Operators
Pin - a PORT.BIT, constant, or variable (0 - 15), that
specifies the I/O pin to use. This pin will automatically
be set to input.
DownState - a variable, constant, or expression (0 or 1)
that specifies which logical state occurs when the button
is pressed.
Delay - a variable, constant, or expression (0 - 255)
that specifies how long the button must be pressed before
auto-repeat starts. The delay is measured in cycles of
the Button routine. Delay has two special settings: 0 and
255. If Delay is 0, Button performs no debounce or auto-
repeat. If Delay is 255, Button performs debounce, but no
auto-repeat.
Rate - a variable, constant, or expression (0 - 255) that
specifies the number of cycles between auto-repeats. The
rate is expressed in cycles of the Button routine.
Workspace - a byte variable used by Button for workspace.
It must be cleared to 0 before being used by Button for
the first time and should not be adjusted outside of the
Button command.
TargetState - a variable, constant, or expression (0 or
1) that specifies which state the button should be in for
a branch to occur. (0 = not pressed, 1 = pressed).
Label - a label that specifies where to branch if the
button is in the target state.
Example
DIM BTNVAR AS BYTE
Loop:
BUTTON 0 , 0 , 255 , 250 , BTNVAR, 0 , NoPress
PRINT "* "
NoPress:
GOTO Loop
Notes
When a button is pressed, the contacts make or break a
connection. A short (1 to 20ms) burst of noise occurs as
the contacts scrape and bounce against each other.
Button's debounce feature prevents this noise from being
interpreted as more than one switch action.
Button also reacts to a button press the way a computer
keyboard does to a key press. When a key is pressed, a
character immediately appears on the screen. If the key
is held down, there's a delay, then a rapid stream of
characters appears on the screen. Button's auto-repeat
function can be set up to work much the same way.
Button is designed for use inside a program loop. Each
time through the loop, Button checks the state of the
specified pin. When it first matches DownState, the
switch is debounced. Then, as dictated by TargetState, it
either branches to address (TargetState = 1) or doesn't
(TargetState = 0).
If the switch stays in DownState, Button counts the
number of program loops that execute. When this count
equals Delay, Button once again triggers the action
specified by TargetState and address. Thereafter, if the
switch remains in DownState, Button waits Rate number of
cycles between actions. The Workspace variable is used by
Button to keep track of how many cycles have occurred
since the pin switched to TargetState or since the last
auto-repeat.
Button does not stop program execution. In order for its
delay and auto repeat functions to work properly, Button
must be executed from within a program loop.
Henry S.
Moderator
Confucius says chà bù duo. Deze post is niet door ChatGPT gegenereerd. De 2019 CO labvoeding.
Move /S&I. Titel verduidelijkt.
Button: Zie manual blz 127.
http://www.picbasic.org/proton_ds_userguide.pdf
[Bericht gewijzigd door Henry S. op ]
Remi
Midiologie.nl. Makers van LPTpushbutton. Als je echt van je hobby houd, laat dom commentaar van anderen je koud.
zal nog eens de help file doorlezen of ik iets meer kan vinden over de serial in en out.
maar dan blijft nog de vraag staan klopt de code een beetje ?
voorbeeld
kan dit ?
Symbol 2led = portD.5 And portD.6
en werkt dit ?
Toggle led1,led2
greets
Remi
Remi
Midiologie.nl. Makers van LPTpushbutton. Als je echt van je hobby houd, laat dom commentaar van anderen je koud.
bedankt voor je input chuck.
ik neem aan dan dat de regel
Symbol 2led = portD.5 And portD.6
niet werkt of overbodig is.
zal voor het serieele gedeelte de handlijding nog eens lezen
en kijken wat ik allemaal vergeet.
ik dacht zeerwaarschijnlijk te simpel.
greets
Remi
LuckyBasterd
:D Eagle addicted!! :D
Op 22 november 2006 18:25:04 schreef Chuck:
Symbol Led1 = portD.5
Symbol Led2 = portD.6Toggle Led1,Led2
werkt
Euh chuck?
ik weet niet hoe of wat. maar ik heb hier proton en ik heb het ook al in mikroC gedaan maar deze link werkt niet met toggle hoor.. Loopt hij tege een error aan.
maar euh.. waarom wil je tegelijk? na elkaar kan toch ook. PIC is toch snelgenoeg?
En anders MikroC
daar lukt het me wel
[Bericht gewijzigd door LuckyBasterd op ]
Remi
Midiologie.nl. Makers van LPTpushbutton. Als je echt van je hobby houd, laat dom commentaar van anderen je koud.
de bedoeling is dat beide leds aan gaan
maar als toggle led1,led2 niet werkt
en toggle led1
toggle led2
wel dan zal het dus zo moeten
zoals ik al zij ik weet nog nites van picbasic en probeer het uit tevogelen hoe hte werkt
greets
remi
Henry S.
Moderator
Confucius says chà bù duo. Deze post is niet door ChatGPT gegenereerd. De 2019 CO labvoeding.
www.picbasic.nl kan helpen. 
En de Proton manual heb je nu ook al.
LuckyBasterd
:D Eagle addicted!! :D
Klopt heb ik ook al na geslagen
en geprobeerd en dan ook gesimuleerd met simulator ide
maar niks.. sorry