Home        Store        Docs        Blog

Feedback of Blue ESC


(Hany Hamed) #1

feedback of blue ESC i use blue ESC with raspberry pi and the data that send from registry when i printed it it seem that it is not correct like the identifier when i printed it it is 0xabab

please ,tell me what is problem that could be made this result.

Thanks


(Rusty) #2

Hi Hany,

Can you please send you code to see if we can identify any issues? The identifier should be 0xab so it seems like you are close to having the right number. The identifier is an 8 bit number so it should not be possible to read 0xabab, which is a 16 bit number.

-Rusty


(Hany Hamed) #3

That is the code

but the signal to send to motor to move is working good
and Thanks for your time.


(Rusty) #4

Hi Hany,

Our website doesn’t allow you to upload some file types. Can you rename the file to “Blue.py.txt” and try again?

Thanks!

Rusty


(Hany Hamed) #5

import smbus
import math
import timeit
bus=smbus.SMBus(1)
class Motor:
def init(self,add):
self.add=add
#bus=smbus.SMBus(1)
bus.write_byte(self.add,0)
bus.write_word_data(self.add,0x00,0)
bus.write_word_data(self.add,0x01,0)
self.bbuffer=[0 for h in range(9)]
self.read_reg=[0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A]
self.rpm1=0
self.voltage_raw=0
self.temp_raw=0
self.current_raw=0
self.identifier=0
self.rpmTimer=0
def millis(self):
return (int(timeit.default_timer()*1000))

def setspeed(self,speed):
self.speed=speed
bus.write_word_data(self.add,0x00,self.speed>>8)
bus.write_word_data(self.add,0x01,self.speed)

def setzeros(self):
bus.write_word_data(self.add,0x00,0)
bus.write_word_data(self.add,0x01,0)

def readBuff(self):
for s in range(0,9):
self.bbuffer[s]=bus.read_word_data(self.add,self.read_reg[s])

def update(self):
self.bbuffer[8]= 0x00
self.readBuff()
self.rpm1 = (self.bbuffer[0] << 8) | self.bbuffer[1]
self.voltage_raw = (self.bbuffer[2] << 8) | self.bbuffer[3]
self.temp_raw = (self.bbuffer[4] << 8) | self.bbuffer[5]
self.current_raw = (self.bbuffer[6] << 8) | self.bbuffer[7]
self.identifier = self.bbuffer[8]
self.rpm1 = float(self.rpm1)/((self.millis()-self.rpmTimer)/1000.000000)*60/float(6)
self.rpmTimer=self.millis()

def isAlive(self):
return (self.identifier == 0xab)

def voltage(self):
#return float(voltage_raw)/65536.0000005.0000006.450000
return self.voltage_raw*0.0004921

def current(self):
#return (float(current_raw)-32767)/65535.0000005.00000014.706000
return (self.current_raw-32767)*0.001122

def temperature(self):
self.resistance = 3300/(65535/float(self.temp_raw)-1)
self.steinhart=0
self.steinhart = self.resistance / 10000
self.steinhart = math.log(self.steinhart)
self.steinhart /= 3900
self.steinhart += 1.0 / (25 + 273.15)
self.steinhart -= 273.15
return self.steinhart

def rpm(self):
return self.rpm1

 

i have add it in the previous post but there is an error

"
<h6>Upload Errors:</h6>

  1. Blue.py: Sorry, this file type is not permitted for security reasons
"

(Hany Hamed) #6

ok thanks

 

blue-py_ (2.01 KB)


(Rusty) #7

Hany,

Okay. Thank you for sharing the code. What output do you see from the data? What do you get if you do:

print self.identifier

-Rusty


(Hany Hamed) #8

i do not remmeber exactly number but when i make this print(‘buffer[8]’,hex(mo1.bbuffer[8]))

it print 0xabab


(Hany Hamed) #9

i will test it again tomorrow and tell you the exact number if you want


(Rusty) #10

Hany,

Okay. Can you run it and also tell us what you get for the other bytes in the bbuffer?

I’m not sure how the bbuffer[8] could be 0xabab since that is a 16 bit number. I think you may be getting correct data but something is causing the identifier to be incorrect.

Please let us know your data tomorrow.

-Rusty


(Hany Hamed) #11

OK , Rusty

i will test it as soon as possible

thanks for your time :slight_smile:


(Hany Hamed) #12

Finally i solve the problem i change the bus.read_word_data with bus.read_byte_data

and it worked

 

Thanks Rusty for your time


(Rusty) #13

Excellent! Thanks for sharing the solution here.

-Rusty