INFO - FAQ - CC2-Forum - CCPro-Forum |
'----------------------------------------------------------------------------------------------------' '***********************************************************************' '* WINDT SYSTEMS *' '* START HELP PAGE FOR PROGRAMMERS of the CCIUM2.01 with CCIAB2.0 *' '* H.J. WINDT *' '* 2004 *' '***********************************************************************' '----------------------------------------------------------------------------------------------------' 'I created this START HELP PAGE to help programmers in getting started with the CCIUM2.01 system.' 'I also included some bug work arounds and subroutines.' 'Included is a deluxe input bug work around for inputting numbers/ hex/ binary and ascii via a' 'terminal program.' 'Download the RS232 TERMINAL at www.b-kainka.de/pcmessfaq.htm.' 'I hope this helps some frustrated CCIUM2.01 programmers!' 'Feel free to use and share this software!' 'SUBROUTINES ARE:' '#check_for_i2c_error' '#check_for_dcf77_synchronization' '#check_for_startkey_pressed' '#deactivate_byteport1' '#deactivate_byteport2' '#input_number_via_232' '----------------------------------------------------------------------------------------------------' '*************** INS and OUTS ***************' '-----byteport 2 lcd connections-----' define db4_sda port[9] 'databus 4, (also used for I2C SDA)' define db5_scl port[10] 'databus 5, (also used for I2C SCL)' define db6 port[11] 'databus 6' define db7 port[12] 'databus 7' define rw port[13] '0 = write to lcd display / 1 = read from lcd display' define rs port[14] '0 = command / 1 = data' define en port[15] '1 to 0 = enable' define lcd_backlight_off port[16] '1 = off / 0 = on' define bport1 byteport[1] '*******************************************' '**************** VARIABLES ****************' define configuration byte[1] define servo_mode bit[1] define counter1 bit[2] define counter2 bit[3] define pullup_resistors_port1 bit[4] define pullup_resistors_port2 bit[5] define dcf77_synchronization bit[6] define i2c_communication_error bit[7] define start_key bit[8] define data word[2] define number word[3] define digit byte[7] define ccium2_version byte[64] '*******************************************' '**************** CONSTANTS ****************' '*******************************************' '****************** SETUP ******************' put 0 'needed because of a bug in CCIUM2.01 rs232 communication' print"#ON_CONFIG#"; 'setting up the configuration for the CCIUM2.01' get configuration servo_mode = 0 '= 1 changes the 2 PWM-DAC ports (da[1], da[2]) into servo mode' counter1 = 0 '= 1 changes the FREQ1 port into a HIGH to LOW active counter, max frequency is about 32767Hz' counter2 = 0 '= 1 changes the FREQ2 port into a HIGH to LOW active counter, max frequency is about 32767Hz' pullup_resistors_port1 = 0 '= 1 activates the internal pullup resistors for byteport[1]' pullup_resistors_port2 = 0 '= 1 activates the internal pullup resistors for byteport[2]' dcf77_synchronization = 0 '= 1 if dcf77 synchronization has occurred' i2c_communication_error = 0 '= 1 if an i2c communication error has occurred' start_key = 0 '= 1 if the start key was pressed' put configuration print"#OFF#"; print"#ON_LCD#"; 'Initializes the lcd and displays the CCIUM2 version' print"#INIT#"; print"#CLR#"; lcd_backlight_off = 0 '= 1 turns the lcd backlight off' print"#L102#"; print"VERSION = "; print ccium2_version; pause 300 print"#CLR#"; print"#OFF#"; '*******************************************' '***************** PROGRAM *****************' #start end '*******************************************' '*************** SUBROUTINES ***************' #check_for_i2c_error 'after return if i2c_communication_error = 1 then a I2C communication error has occurred' print"#ON_CONFIG#"; get configuration if i2c_communication_error = 0 then goto pass_i2c_error_clear i2c_communication_error = 0 put configuration i2c_communication_error = 1 #pass_i2c_error_clear print"#OFF#"; return '--------------------------------------------------------------------------------------------------------------------' #check_for_dcf77_synchronization 'after return if dcf77_synchronization = 1 then synchronization has occurred' print"#ON_CONFIG#"; get configuration if dcf77_synchronization = 0 then goto pass_dcf77_synchronization_clear dcf77_synchronization = 0 put configuration dcf77_synchronization = 1 #pass_dcf77_synchronization_clear print"#OFF#"; return '--------------------------------------------------------------------------------------------------------------------' #check_for_startkey_pressed 'after return if start_key = 1 then the start key was pressed' print"#ON_CONFIG#"; get configuration if start_key = 0 then goto pass_start_key_clear start_key = 0 put configuration start_key = 1 #pass_start_key_clear print"#OFF#"; return '--------------------------------------------------------------------------------------------------------------------' #deactivate_byteport1 'deactivates byteport 1' deact bport1 return '--------------------------------------------------------------------------------------------------------------------' #deactivate_byteport2 'deactivates byteport 2/ lcd is connected to this port' deact en : deact rw : deact rw : deact db7 : deact db6 : deact db5_scl : deact db4_sda return '--------------------------------------------------------------------------------------------------------------------' #input_number_via_232 'input bug work around/ +-variables, hex &h.., binary &b..., ascii &a. are supported' number = 0 digit = 0 get data 'get 8 bit ascii code' if data = 8 then goto input_number_via_232 'look for ascii code for BACKSPACE' if data = 13 then return 'look for ascii code for ENTER' if data = 38 then goto check_for_hex_or_bin_or_ascii 'look for ascii code for &' if data = 45 then goto input_negative_dec 'look for ascii code for -' #input_positive_dec digit = digit + 1 data = data - 48 'translate ascii code into decimal' if number <> 0 then number = number * 10 + data else number = data 'build number' #input_positive_backspace_loop get data 'get 8 bit ascii code' if data = 8 then number = number / 10 'debuild number if ascii code for BACKSPACE is recieved' if data = 8 then digit = digit - 1 if digit = 0 then goto input_number_via_232 'go back if no more digits are displayed' if data = 8 then goto input_positive_backspace_loop if data = 13 then return 'look for ascii code for ENTER' goto input_positive_dec #input_negative_dec digit = digit + 1 #input_negative_backspace_loop get data 'get 8 bit ascii code' if data = 8 then number = number / 10 'debuild number if ascii code for BACKSPACE is recieved' if data = 8 then digit = digit - 1 if digit = 0 then goto input_number_via_232 'go back if - is no longer displayed' if data = 8 then goto input_negative_backspace_loop if data = 13 then number = number * -1 'look for ascii code for ENTER and make number negative if so' if data = 13 then return 'look for ascii code for ENTER' data = data - 48 'translate ascii code into decimal' if number <> 0 then number = number * 10 + data else number = data 'build number' goto input_negative_dec #check_for_hex_or_bin_or_ascii digit = digit + 1 #check_for_hex_or_bin_or_ascii_loop get data 'get 8 bit ascii code' if data = 8 then digit = digit - 1 if digit = 0 then goto input_number_via_232 'go back if & is no longer displayed' if data = 8 then goto check_for_hex_or_bin_or_ascii_loop if data = 98 then goto input_binary 'look for ascii code for b' if data = 66 then goto input_binary 'look for ascii code for B' if data = 104 then goto input_hex 'look for ascii code for h' if data = 72 then goto input_hex 'look for ascii code for H' if data = 97 then goto input_ascii 'look for ascii code for a' if data = 65 then goto input_ascii 'look for ascii code for A' number = 0 'if wrong letter is pressed then number = 0' get data 'wait for key to be pressed' return #input_binary digit = digit + 1 #input_binary_loop get data 'get 8 bit ascii code' if data = 8 then number = number shr 1 'debuild number if ascii code for BACKSPACE is recieved' if data = 8 then digit = digit -1 if digit = 1 then goto check_for_hex_or_bin_or_ascii_loop 'go back if b or B is no longer displayed' if data = 8 then goto input_binary_loop if data = 13 then return 'look for ascii code for ENTER' data = data - 48 'translate ascii code into decimal' if number <> 0 then number = number shl 1 or (data and 1) else number = (data and 1) 'build number' goto input_binary #input_hex digit = digit + 1 #input_hex_loop get data 'get 8 bit ascii code' if data = 8 then number = number shr 4 'debuild number if ascii code for BACKSPACE is recieved' if data = 8 then digit = digit -1 if digit = 1 then goto check_for_hex_or_bin_or_ascii_loop 'go back if h or H is no longer displayed' if data = 8 then goto input_hex_loop if data = 13 then return 'look for ascii code for ENTER' if data > 70 then data = data - 87 else if data > 57 then data = data - 55 else data = data - 48 'translate ascii code into decimal' if number <> 0 then number = number shl 4 or data else number = data 'build number' goto input_hex #input_ascii get number 'get 8 bit ascii code/ build number' return '*******************************************' '****************** DATA *******************' '*******************************************' |
Antwort schreiben |