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 Windt H.J. - 2.07.2005 16:50)
 Als Antwort auf RN-Motor an I2C-Bus von Gaston - 1.07.2005 3:05
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:

Re: RN-Motor an I2C-Bus (von Gaston - 3.07.2005 14:53)
    Re: RN-Motor an I2C-Bus (von Windt H.J. - 3.07.2005 17:31)
        Re: RN-Motor an I2C-Bus (von Gaston - 3.07.2005 18:19)
            Re: RN-Motor an I2C-Bus (von Windt H.J. - 4.07.2005 2:08)
                Re: RN-Motor an I2C-Bus (von Gaston - 4.07.2005 11:56)
                    Re: RN-Motor an I2C-Bus (von Windt H.J. - 4.07.2005 13:28)
                       Re: RN-Motor an I2C-Bus (von Gaston - 4.07.2005 13:59)
                          Re: RN-Motor an I2C-Bus (von Windt H.J. - 4.07.2005 14:39)
                             Re: RN-Motor an I2C-Bus (von Gaston - 4.07.2005 14:48)
                                Re: RN-Motor an I2C-Bus (von Windt H.J. - 4.07.2005 15:00)
                                   Re: RN-Motor an I2C-Bus (von Gaston - 4.07.2005 15:12)
                                     Re: RN-Motor an I2C-Bus (von Windt H.J. - 4.07.2005 18:24)
                                       Re: RN-Motor an I2C-Bus (von Gaston - 5.07.2005 10:59)
                                         Re: RN-Motor an I2C-Bus (von Windt H.J. - 5.07.2005 14:10)
                                           Re: RN-Motor an I2C-Bus (von Gaston - 5.07.2005 17:48)
                                             Re: RN-Motor an I2C-Bus (von Windt H.J. - 5.07.2005 19:00)
                                               Re: RN-Motor an I2C-Bus (von Gaston - 7.07.2005 16:00)
Re: RN-Motor an I2C-Bus (von Gaston - 3.07.2005 9:59)