Das Open-Control-Projekt - Die Alternative zur C-Control-I


Das Forum zur C-Control-1
Welche C-Control-Varianten existieren?
Übersicht - Suchen - Neueste 50 Beiträge - Neuer Beitrag - Login - Registrieren
INFO - FAQ - CC2-Forum - CCPro-Forum 

 Re: RN-Motor an I2C-Bus Kategorie: C-Control I V1.2/2.0 (von Gaston - 3.07.2005 9:59)
 Als Antwort auf Re: RN-Motor an I2C-Bus von Windt H.J. - 2.07.2005 16:50
That works perfectly!  Many thanks!!!!
And there are no error messages at all.
Is it also possible to do the read-out functions like "show configuration" code 11
and "read out number of steps" code 13?
Greetings
Gaston




> I have looked thru the pdf file of the RN-MOTOR and have written an example for you to try, let me know how it works out.
> Greetings,
> H.J. Windt
>
> '----------------------------------------------------------------------------------------------------'
> 'Try this example for the RN-MOTOR, look under *** I/O PORTS *** for the I2C connections.'
> 'You may want to adjust some variables to make the RN-MOTOR work with your motors!!'
> '----------------------------------------------------------------------------------------------------'
> '**************** I/O PORTS ****************'
> define sda port[4]
> define scl port[5]
> '*******************************************'
> '**************** VARIABLES ****************'
> define i2c_nack bit[1]
> define i2c_last bit[2]
> define i2c_nack_count byte[2]
> define i2c_byte byte[3]
> define i2c_out_bit bit[24]
> define i2c_in_bit bit[17]
> define loop byte[4]
> '*******************************************'
> '**************** CONSTANTS ****************'
>
> '*******************************************'
> '****************** SETUP ******************'
> print"#ON_CONFIG#"; : put &b1000 : print"#OFF#";
> '*******************************************'
> '***************** PROGRAM *****************'
> #start
>
> #set_motor_amps
> gosub start_i2c
> i2c_byte = &h56 : gosub write_byte_i2c
> i2c_byte = 10 : gosub write_byte_i2c
> i2c_byte = 1 : gosub write_byte_i2c
> i2c_byte = 2 : gosub write_byte_i2c
> i2c_byte = 190 : gosub write_byte_i2c
> i2c_byte = 255 : gosub write_byte_i2c
> gosub stop_i2c
> if i2c_nack_count > 18 then goto no_ack_from_i2c_device
> if i2c_nack then goto set_motor_amps
>
> #set_mode
> gosub start_i2c
> i2c_byte = &h56 : gosub write_byte_i2c
> i2c_byte = 10 : gosub write_byte_i2c
> i2c_byte = 14 : gosub write_byte_i2c
> i2c_byte = 0 : gosub write_byte_i2c
> i2c_byte = 255 : gosub write_byte_i2c
> i2c_byte = 255 : gosub write_byte_i2c
> gosub stop_i2c
> if i2c_nack_count > 18 then goto no_ack_from_i2c_device
> if i2c_nack then goto set_mode
>
> #switch_motor_on
> gosub start_i2c
> i2c_byte = &h56 : gosub write_byte_i2c
> i2c_byte = 10 : gosub write_byte_i2c
> i2c_byte = 10 : gosub write_byte_i2c
> i2c_byte = 2 : gosub write_byte_i2c
> i2c_byte = 255 : gosub write_byte_i2c
> i2c_byte = 255 : gosub write_byte_i2c
> gosub stop_i2c
> if i2c_nack_count > 18 then goto no_ack_from_i2c_device
> if i2c_nack then goto switch_motor_on
>
> #set_motor_direction
> gosub start_i2c
> i2c_byte = &h56 : gosub write_byte_i2c
> i2c_byte = 10 : gosub write_byte_i2c
> i2c_byte = 4 : gosub write_byte_i2c
> i2c_byte = 2 : gosub write_byte_i2c
> i2c_byte = 1 : gosub write_byte_i2c
> i2c_byte = 255 : gosub write_byte_i2c
> gosub stop_i2c
> if i2c_nack_count > 18 then goto no_ack_from_i2c_device
> if i2c_nack then goto set_motor_direction
>
> #set_motor_speed
> gosub start_i2c
> i2c_byte = &h56 : gosub write_byte_i2c
> i2c_byte = 10 : gosub write_byte_i2c
> i2c_byte = 8 : gosub write_byte_i2c
> i2c_byte = 2 : gosub write_byte_i2c
> i2c_byte = 200 : gosub write_byte_i2c
> i2c_byte = 255 : gosub write_byte_i2c
> gosub stop_i2c
> if i2c_nack_count > 18 then goto no_ack_from_i2c_device
> if i2c_nack then goto set_motor_speed
>
> #motor_endless_loop
> gosub start_i2c
> i2c_byte = &h56 : gosub write_byte_i2c
> i2c_byte = 10 : gosub write_byte_i2c
> i2c_byte = 6 : gosub write_byte_i2c
> i2c_byte = 2 : gosub write_byte_i2c
> i2c_byte = 255 : gosub write_byte_i2c
> i2c_byte = 255 : gosub write_byte_i2c
> gosub stop_i2c
> if i2c_nack_count > 18 then goto no_ack_from_i2c_device
> if i2c_nack then goto motor_endless_loop
>
> end
> '*******************************************'
> '*************** SUBROUTINES ***************'
> #start_i2c
> sda = 0 : scl = 0
> return
>
> #stop_i2c
> sda = 0 : deact scl : deact sda
> return
>
> #write_byte_i2c
> for loop = 1 to 8
> sda = i2c_out_bit
> deact scl
> #write_byte_i2c_clock_stretch
> if not scl then goto write_byte_i2c_clock_stretch
> scl = 0
> i2c_byte = i2c_byte shl 1
> next
> deact sda
> deact scl
> #write_byte_i2c_ack_clock_stretch
> if not scl then goto write_byte_i2c_ack_clock_stretch
> i2c_nack = sda
> scl = 0
> if i2c_nack then goto i2c_error
> i2c_nack_count = 0
> return
> #i2c_error
> i2c_nack_count = i2c_nack_count + 1
> goto stop_i2c
> '*******************************************'
> '******* INITIALIZATION SUBROUTINES ********'
>
> '*******************************************'
> '****************** DATA *******************'
>
> '*******************************************'
> '************* ERROR MESSAGES **************'
> #no_ack_from_i2c_device
> print"**************************"
> print"* No ACK from I2C device *"
> print"**************************"
> pause 50
> goto no_ack_from_i2c_device
> '*******************************************'
>
> >
> >
> > Hallo,
> >
> > ich versuche seit Tagen die Schrittmotorsteuerung RN-Motor über den I2C-Bus einer C-Control-1 M-Unit V2.0 anzusteuern und bekomme es einfach nicht hin. Hat vielleicht jemand das Problem schon gelöst und wäre bereit mich vor der Verzweiflung zu retten?
> >
> > Vielen Dank im Voraus für die Hilfe
> >
> >
>

 Antwort schreiben

Bisherige Antworten: