PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Gibt es in BASIC++ einen Befehl wie PULSE in CCBASIS



DaSilver
31.05.2007, 11:55
Hallo,

ich betreibe an meiner alten C-Control einen SRF04 Sensor. Die benötigte Schaltung und Teile des Quellcodes habe ich hier entnommen: http://www.robotmaker.de/srf04.htm

Da ich eine neue C-control habe, möchte ich das Programm gerne von CCBASIC nach BASIC++ umschreiben. Allerdings habe ich gelesen, dass es den Befehl Pulse nicht in BASIC++ gibt.

Der betreffenden CodeSchnipsel:


Distanz = 0 ' Die Variable bekommt auch den Wert Null
Start = 0 ' Der Startport wird ebenfalls zu Null
Reset = 1 ' Und die Schaltung wird erst mal resetet

Pause 1 ' Wegen dem Reseten müssen wir kurz warten

'------------------------------------------------------------

#Anfang ' Das Programm wird jetzt gestartet!

Reset = 0 ' Der Reset-Port wird ausgeschaltet,
Pulse Start ' Und wir geben einen Impuls auf den Triggereingang
Pause 1 ' Die Schaltung misst und wir muessen kurz warten (20ms)

Distanz = Messen ' Das Messergebnis wird nun in die Variable uebertragen


Oder gibt es eine andere Möglichkeit?

Gruß
Silver

Dirk
01.06.2007, 14:50
Ich kenne Basic++ nicht, aber PULSE in CCBASIC invertiert einen Port für kurze Zeit.
Das müßte im Hauptprogramm in Basic++ auch etwa so gehen:
PortXY = 0
Gosub Pulse
...

Und das Unterprogramm sieht in etwa so aus:
Pulse:
Toggle PortXY
Waitms 1
Toggle PortXY
Return

... und du hast das gleiche wie PULSE.
Wenn es Toggle in Basic++ nicht gibt, kannst du das ersetzen durch:
PortXY = 1
Waitms 1
PortXY = 0

Gruß Dirk

Dierk
01.06.2007, 19:21
Allerdings habe ich gelesen, dass es den Befehl Pulse nicht in BASIC++ gibt.
Wo hast Du denn das gelesen? Natürlich gibt es den Pulse-Befehl auch in Basic++. Probiers einfach mal aus ;)

DaSilver
02.06.2007, 11:49
Hallo,

Danke für die Info.

gelesen habe ich das hier im Downloadbereich. Da gibt es eine kleine Anleitung wie ich einen SRF04 Sensor ansprechen kann und da stand folgendes:

'The SRF04 SIGNAL CONVERTER is easy to build and is necessary because the CCIUM2.01 has no'
'pulse width measuring command.'
Ich hatte dies so interpretiert, dass es den Befehl pulse nicht in Basic++ gibt. Werde das aber auf jeden Fall ausprobieren - wenn ich das USB-Serial Problem gelöst habe / mein Rechner hat kein Serial und ich kann meine Station nicht ansprechen, das steht aber in einem anderen Beitrag.

Gruß
Silver

Dierk
02.06.2007, 13:42
pulse width measuring command
In etwa übersetzt heißt das "Befehl für Pulsweitenmessung". ;)
Und es steht da auch nichts von Basic++, welches nicht nur für die M2.00 verwendet werden kann. Also da hast Du etwas vollkommen falsch verstanden.

DaSilver
04.06.2007, 07:56
Hallo,

mein Englisch ist leider nicht so gut, wie es sein könnte ;-(

Der Quellcode, den ich vielleicht auch hätte anhängen sollen, sah nach Basic++ aus. Den Code habe ich jetzt angehängt.

'----------------------------------------------------------------------------------------------------'
'************************************************* **********************'
'* WINDT SYSTEMS *'
'* SRF04 RANGE MEASURING v1.0 for CCIUM2.01 with CCIAB2.0 *'
'* H.J. WINDT *'
'* 2004 *'
'************************************************* **********************'
'-------------------------------------------------------------------------------------------------------'
'This SRF04 example program will trigger the SRF04 module and read the return signal via the'
'SRF04 SIGNAL CONVERTER, see the schematic, and display the range in cm on the LCD.'
'The SRF04 SIGNAL CONVERTER is easy to build and is necessary because the CCIUM2.01 has no'
'pulse width measuring command.'
'When the ECHO PULSE OUTPUT from the SRF04 goes HIGH, the SRF04 SIGNAL CONVERTER will start'
'pulsing and stop when the ECHO PULSE OUTPUT from the SRF04 goes LOW.'
'The CCIUM2.01 will count these pulses and display the counted number on the LCD,'
'this number corresponds to the range in cm.'
'Calibration is necessary, but easy to do, after connecting everything up(see schematic for connections)'
'and uploading the example, run the program and aim the SRF04 at a object that is 3 meters away and'
'adjust the R2 5K variable resistor until the LCD displays "Range = 300cm" and done!'
'Feel free to use and share the software!'
'-------------------------------------------------------------------------------------------------------'
'*************** INS and OUTS **************'
define srf04_start port[1]
define counter freq2
define lcd_light_off port[16]
'*******************************************'
'**************** VARIABLES ****************'
define config byte[1]
define counter_mode bit[3]
define loop byte[2]
define range word[2]
'*******************************************'
'**************** CONSTANTS ****************'

'*******************************************'
'****************** SETUP ******************'
print"#ON_CONFIG#"; 'Change freq2 to counter mode'
get config
counter_mode = 1
put config
print"#OFF#";

print"#ON_LCD#"; 'Initialize LCD'
print"#INIT#";
print"#CLR#";
print"#OFF#";

srf04_start = 0
pause 50
lcd_light_off = 0
'*******************************************'
'***************** PROGRAM *****************'
#start
print"#ON_LCD#";
gosub measure_range
print"#L101#";
print"Range = ";
print range;
print"cm";
print" ";
print"OFF";
goto start
'*******************************************'
'*************** SUBROUTINES ***************'
#measure_range
pause 2
counter = 0 'reset the counter'
tog srf04_start 'trigger the srf04'
tog srf04_start
#wait_for_measuring_to_end
range = counter
for loop = 1 to 30
next
if counter > range then goto wait_for_measuring_to_end
return
'*******************************************'
'****************** DATA *******************'

'*******************************************'

Vielleicht habe ich mich vertan, ich habe bis jetzt noch nichts in Basic++ programmiert. Vielen Dank für die Information. Ich probiere das mal aus, wenn ich das Adapterproblem geölst habe.

Gruß
Silver

Dierk
04.06.2007, 08:41
Ja mach das. Du solltest übrigens den Bit-Ports kein 0 und 1 zuweisen sondern mit on/off oder true/false setzen.

Peach303
31.12.2007, 14:02
Hi,


'This SRF04 example program will trigger the SRF04 module and read the return signal via the'
'SRF04 SIGNAL CONVERTER, see the schematic, and display the range in cm on the LCD.'
'The SRF04 SIGNAL CONVERTER is easy to build and is necessary because the CCIUM2.01 has no'
'pulse width measuring command.'

Was ist der SRF04 SIGNAL CONVERTER? Ist das eine Schaltung? Wo kann ich ein Layout dafür herbekommen? Gibts einen Link?

Vielen Dank, Gruß,
Daniel

Drifter2006
31.12.2007, 14:54
Hi,


'This SRF04 example program will trigger the SRF04 module and read the return signal via the'
'SRF04 SIGNAL CONVERTER, see the schematic, and display the range in cm on the LCD.'
'The SRF04 SIGNAL CONVERTER is easy to build and is necessary because the CCIUM2.01 has no'
'pulse width measuring command.'

Was ist der SRF04 SIGNAL CONVERTER? Ist das eine Schaltung? Wo kann ich ein Layout dafür herbekommen? Gibts einen Link?

Vielen Dank, Gruß,
Daniel

Hello,
The schematic is provided in the download. -> https://www.roboternetz.de/phpBB2/dload.php?action=file&file_id=250

Other downloads -> https://www.roboternetz.de/phpBB2/dload.php?action=category&cat_id=26

Greetings,
Windt H.J.

Peach303
31.12.2007, 15:02
Thank you very much!

And "Gutes Neues" :)

Daniel