Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Trying to read reg 8 drv2605 in CiPy
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Trying to read reg 8 drv2605 in CiPy

by jimmyz5150 on Tue Jun 02, 2020 6:56 pm

Newish to CirPy, trying to convert Ardiuno over to Cirpy using M4 express
I am trying to convert a read reg over to CircuitPython
I am stuck on how to read and print the bytes
this is working code in Arduino
Code: Select all | TOGGLE FULL SIZE
int id1 = 0;  int id11 = 0; int emf1 = 0;
void drvResults(){
tcaselect(1); drv1.begin();
uint8_t id1 = drv1.readRegister8(0x00);//REG_STATUS
  Serial.print("drv#1 RegStatus 0x00 = ");  Serial.println(id1, BIN);
uint8_t id11 = drv1.readRegister8(0x18);//ACalComp
  Serial.print("drv#1 ACalComp  0x18 = ");  Serial.println(id11, BIN);
uint8_t emf1 = drv1.readRegister8(0x19);//BackEMF
  Serial.print("drv#1 Back-EMF Results  0x19 = ");  Serial.println(emf1, HEX);
int vBatVal_1 = drv1.readRegister8(DRV2605_REG_VBAT);
  float vdd1 = vBatVal_1 * (5.2 / 255.0);
  Serial.print("-- drv#1 Reg_vBat Vout = ");Serial.println(vdd1, 3);


I've tried to watch TonyD's video on i2c (didn't quite seem relevant to my case) and follow CirPy doc: https://learn.adafruit.com/circuitpytho ... 2c-devices
I am able to start a scan but cannot grab values to print
Any help would be great

jimmyz5150
 
Posts: 102
Joined: Tue Apr 04, 2017 1:19 pm

Re: Trying to read reg 8 drv2605 in CiPy

by jerryn on Wed Jun 03, 2020 8:38 am

Just FyI -- there is a CircuitPython library for the drv2605. https://github.com/adafruit/Adafruit_CircuitPython_DRV2605 and guide https://learn.adafruit.com/adafruit-drv2605-haptic-controller-breakout/python-circuitpython?preview_token=Q0DdzmOVqBtCzHgmuDB-hQ
If you can't use it directly, the code may help you write your own.

jerryn
 
Posts: 1299
Joined: Sat Sep 14, 2013 9:05 am

Re: Trying to read reg 8 drv2605 in CiPy

by jimmyz5150 on Wed Jun 03, 2020 9:31 am

Thanks @ jerryn,
But I'm past those links.. I have a working Py code. Managed to rewrite other code I had into Py. (with help of Carter@Ada getting the TCA and DRV passing through)
My problem lies in that... The DRV2605l boards (I have 6 with a TCA mux) have information that I get from them... such as
calibration passing, ACal, Back EMF, Voltage output.

I can't figure out how to directly access the DRV2605 in Python i.e. REG 0x00, 0x18, 0x19 and VBat. These are important
reg's info to have.
I've been use to Arduino's C++, so the coding in the 1st post is my remaining monster, I think LOL

jimmyz5150
 
Posts: 102
Joined: Tue Apr 04, 2017 1:19 pm

Re: Trying to read reg 8 drv2605 in CiPy

by shamsmehra90 on Mon Jun 08, 2020 12:42 pm

Thanks for sharing but i think it have some issue

shamsmehra90
 
Posts: 2
Joined: Mon Jun 08, 2020 12:40 pm

Re: Trying to read reg 8 drv2605 in CiPy

by jimmyz5150 on Mon Jun 08, 2020 12:52 pm

what is that suppose to mean??

jimmyz5150
 
Posts: 102
Joined: Tue Apr 04, 2017 1:19 pm

Re: Trying to read reg 8 drv2605 in CiPy

by adafruit_support_carter on Tue Jun 09, 2020 11:40 am

You can use the _read_u8 and _write_u8 functions to read/write single byte values to specified registers.
https://github.com/adafruit/Adafruit_Ci ... 05.py#L128
https://github.com/adafruit/Adafruit_Ci ... 05.py#L135

The leading underscore indicates the function is "private" and generally should not be called directly. But that is just a naming convention. Python will let you call those functions directly if you want.

adafruit_support_carter
 
Posts: 16922
Joined: Tue Nov 29, 2016 2:45 pm

Re: Trying to read reg 8 drv2605 in CiPy

by jimmyz5150 on Tue Jun 09, 2020 9:23 pm

thanks Carter will look at it... but it's more of the writing of the code, bc I can't get it right

jimmyz5150
 
Posts: 102
Joined: Tue Apr 04, 2017 1:19 pm

Re: Trying to read reg 8 drv2605 in CiPy

by shamsmehra90 on Tue Jul 21, 2020 3:47 pm

Thanks guys finally the issue is solved! ..

shamsmehra90
 
Posts: 2
Joined: Mon Jun 08, 2020 12:40 pm

Please be positive and constructive with your questions and comments.