I2C , Robit Elecfreaks

Questions and discussion about running MicroPython on a micro:bit board.
Target audience: MicroPython users with a micro:bit.
User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: I2C , Robit Elecfreaks

Post by dhylands » Fri Oct 04, 2019 4:12 pm

Normally, an H-Bridgge will have a direction GPIO line and a PWM line to control the speed.

Do you have schematics available? It's hard to know what exactly needs to be done without knowing exactly how things are wired up.

francois69
Posts: 9
Joined: Mon Sep 23, 2019 4:38 pm

Re: I2C , Robit Elecfreaks

Post by francois69 » Sat Oct 05, 2019 5:06 pm

No i have not any schematics. I have wrote to Electfreaks but they never answer.
I just hope that somebody who can understant the program:
https://github.com/Tinkertanker/pxt-rob ... r/robit.ts
Could understant how i can do.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: I2C , Robit Elecfreaks

Post by dhylands » Sat Oct 05, 2019 10:55 pm

Looking at the code, there appears to be 2 PWM lines going to the H-Bridge (rather than a simple direction/PWM) and you control the direction by sending PWM to one line or the other to control the direction.

francois69
Posts: 9
Joined: Mon Sep 23, 2019 4:38 pm

Re: I2C , Robit Elecfreaks

Post by francois69 » Sat Oct 05, 2019 11:56 pm

thank you
i have find the solution. Indeed each motor is controled by 2 groups of 4 registers.
I show the program :

from microbit import *
print(i2c.scan())
sleep(20)
i2c.write(64, b'\x00\x20') # Mode1: bit5=1(auto increment enable)
# motor 1 (x06 and x0A), duty cycle = 50%, start on = 0 start off= 2047
# LED0_ON_L + LED0_ON_H = 0 LED0_OFF_L + LED0_OFF_H =7FF (2047)
i2c.write(64, b'\x06\x00\x00\xFF\x07') # rotation foward
i2c.write(64, b'\x0A\x00\x00\x00\x00') # rotation reverse
# motor 2 (x0E and x12), duty cycle = 50%, start on = 0 start off= 2047
# LED0_ON_L + LED0_ON_H = 0 LED0_OFF_L + LED0_OFF_H =7FF (2047)
i2c.write(64, b'\x0E\x00\x00\xFF\x07') # rotation reverse
i2c.write(64, b'\x12\x00\x00\x00\x00') # rotation foward
i2c.write(64, b'\x06')
print(i2c.read(64, 16))

I am really happy . Tank's a lot. I think you can write "Resolved"
François

Post Reply