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.
Code:
'----------------------------------------------------------------------------------------------------'
'***********************************************************************'
'* 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
Lesezeichen