Intel® Makers
Intel® Edison, Intel® Joule™, Intel® Curie™, Intel® Galileo
Announcements
Welcome - This is a Peer-to-Peer Forum only. Intel has discontinued these products but you may find support from other customers on this Forum
9881 Discussions

Doing add-ons of the UPM sensor (smartdrive) to javascript and python

nDE_S
New Contributor I
3,001 Views

Hi guys,

I did this driver ( https://github.com/intel-iot-devkit/upm/blob/master/examples/c%2B%2B/smartdrive.cxx https://github.com/intel-iot-devkit/upm/blob/master/examples/c%2B%2B/smartdrive.cxx) in partnership with driver

 

Oussema Harbi mailto:oussema.elharbi@gmail.com oussema.elharbi@gmail.com

What I need now to do var smart= require('smartdrive') and use smart variable to move windshield motors to left and right in my javascript code?

e.g.: SmartDrive High Current Motor Controller is originally sold with a python software driver to raspberry pi. I worked in last year to solve problems and make the driver works in intel edison

 

(/thread/88007 https://communities.intel.com/thread/88007)
0 Kudos
62 Replies
idata
Community Manager
248 Views

Hi Neuberfran,

 

 

I've been doing my best to help you, and I understand what you want to achieve, however, since your final goal is to adapt your Python code into a C++ version, I won't be able to help you with that since it's not actually an issue with Edison. The C++ code example works with Edison, any modification would have to be done by the end user so you will have to try to adapt the code by yourself.

 

 

To accomplish this, I highly recommend you to understand what the C++ code does in every part, and try to adapt your Python script part by part. The C++ code is quite extensive and it will be difficult to modify it, so the best approach would be to go part by part. Test and make sure a particular function works before going to the next one.

 

 

Have a nice day.

 

 

Regards,

 

-Leonardo
nDE_S
New Contributor I
248 Views

Hi -Leonardo,

I understood you. I need one more help or answer about one question

What You think about this:

When I run https://github.com/neuberfran/SmartDrive-demo/blob/master/SmartDrive-demo.py https://github.com/neuberfran/SmartDrive-demo/blob/master/SmartDrive-demo.py

After reboot my intel Edison with old image, the motor don't run. After I run m2ctool scan 6 command

(https://github.com/m2aglabs/m2ctool https://github.com/m2aglabs/m2ctool) everything work ok

idata
Community Manager
248 Views

Hi Neuberfran,

 

 

Well it looks like a problem with the initialization of the I2C port, and maybe when you do the scan it initializes. Personally, I recommend you to check this example of the MRAA repository ( https://github.com/intel-iot-devkit/mraa/blob/master/examples/python/bmp85.py), to see how it works, and try to adapt the MRAA initialization on the Python code.

 

 

I hope you find this useful.

 

 

Have a nice weekend.

 

 

Regards,

 

-Leonardo
nDE_S
New Contributor I
248 Views

Hi -Leonardo,

I put a PATH variable and received new errors that solved certainly solved my problem

* The above error message files are all here:

https://github.com/neuberfran/SmartDrive-issue

idata
Community Manager
248 Views

Hi Neuberfran,

 

 

I'm a little confused, why did you set the PATH? Now you are having more errors than before.

 

 

Did you try my recommendations? Try to initialize the I2C port in the SmartDrive-demo.py.

 

 

Have a nice day.

 

 

Regards,

 

-Leonardo
nDE_S
New Contributor I
248 Views

Hi -Leonardo,

How to I do this? I tried a few things and I received or mistake or did not work

https://github.com/neuberfran/SmartDrive-demo/blob/master/SmartDrive.py SmartDrive-demo/SmartDrive.py at master · neuberfran/SmartDrive-demo · GitHub

https://github.com/neuberfran/SmartDrive-demo/blob/master/OpenElectrons_i2c.py SmartDrive-demo/OpenElectrons_i2c.py at master · neuberfran/SmartDrive-demo · GitHub

idata
Community Manager
248 Views

Hi Neuberfran,

 

 

Could you please explain us a little bit more about the issue? In previous posts we were discussing another subject, and I'm a little confused about your last replies. They seem to be completely about another issue.

 

 

Please try to help me to understand, it is hard to analyze the error if you just post a screenshot of your code without any explanation. Please keep in mind that I won't be able to help you with your goal of adapting the Python code into a C++ version because that's not an issue with Edison itself but a general programming matter.

 

 

The examples provided for Edison work correctly and any modifications to them have to be done by the end users. I will try to assist you of course, and I will always try to do my best to help you, but I won't be able to write the entire code.

 

 

Regards,

 

-Leonardo
nDE_S
New Contributor I
248 Views

Hi -Leonardo,

You do not have to write the whole code.

You only need help me adapt this part

x = m.I2c(0)

x.address(0x77)

to this:

https://github.com/neuberfran/SmartDrive-demo/blob/master/SmartDrive.py SmartDrive-demo/SmartDrive.py at master · neuberfran/SmartDrive-demo · GitHub

https://github.com/neuberfran/SmartDrive-demo/blob/master/OpenElectrons_i2c.py SmartDrive-demo/OpenElectrons_i2c.py at master · neuberfran/SmartDrive-demo · GitHub

and this:

https://github.com/neuberfran/SmartDrive-demo/blob/master/SmartDrive-demo.py SmartDrive-demo/SmartDrive-demo.py at master · neuberfran/SmartDrive-demo · GitHub

idata
Community Manager
248 Views

Hi Neuberfran,

 

 

I think you have to add the following lines in the beginning of your code ( https://github.com/neuberfran/SmartDrive-demo/blob/master/SmartDrive-demo.py):

 

 

x = m.I2c(0)

 

x.address(Smartdrive address)

 

 

I know you did it, but you don't have to change the x for Smartdrive, and then you add your code.

 

 

I hope this works for you.

 

 

Regards,

 

-Leonardo
nDE_S
New Contributor I
248 Views

Hi -Leonardo,

I keep getting errors

idata
Community Manager
248 Views

Hi Neuberfran,

 

 

I'm not sure why the sensor couldn't read the values, the problem is that I can't test it, because I don't have the sensor.

 

 

Maybe you have to initialize the device (Check the example provided https://github.com/intel-iot-devkit/mraa/blob/master/examples/python/bmp85.py) with the following lines:

 

 

# initialize device if x.readReg(0xd0) != 0x55:  print("error")

 

 

Let me know if it works for you.

 

 

Have a nice day.

 

 

Regards,

 

-Leonardo
nDE_S
New Contributor I
248 Views

Hi -Leonardo,

According to this site: http://qiita.com/satorukun/items/e2577ad2e3d03b46c80d Raspberry Pi 2 Model B でI2C 気圧+温度センサーモジュール(BMP180)を使う - Qiita

the command : sudo i2cget -y 1 0x77 0xD0 b

I will need help to use this command with my device (smartdrive) list below

idata
Community Manager
248 Views

Hi Neuberfran,

 

 

According to the result of i2cdetect command, the Smartdrive has the following address: 0x1b.

 

 

When you use the i2cget you have to read one specific register, so it depends what register you want to read.

 

 

I think that the following command should work:

 

 

sudo i2cget -y 1 0x1b 0x5B b

 

 

If you get an error with the register, please check here what register you can use: https://github.com/neuberfran/SmartDrive-demo/blob/master/SmartDrive.py

 

 

I hope this works for you.

 

 

Regards,

 

-Leonardo
nDE_S
New Contributor I
248 Views

Hi -Leonardo,

Now I can run SmartDrive-demo.py when I start edison Without need of before run m2ctool scan 6 (As I had been having this error before)

By the way, I ask:

Would the correct one would not be to use the address of 7 bits (0x1b instead of 0x36) in this project: https://github.com/intel-iot-devkit/upm/tree/master/src/smartdrive upm/src/smartdrive at master · intel-iot-devkit/upm · GitHub ?

(I ask this because in this project https://github.com/intel-iot-devkit/mraa/blob/master/examples/python/bmp85.py mraa/bmp85.py at master · intel-iot-devkit/mraa · GitHub was used address of 7 bits (0x77)

i2cget command yet error:

idata
Community Manager
248 Views

Hi Neuberfran,

 

 

Well, it is good to know that you can run it without problems.

 

 

About your question, it makes sense, so yes I think you should use the 7 bit address with the MRAA library.

 

 

Did you try to read another register with the i2cget command? If you don't please try it (Check the registers here: https://github.com/neuberfran/SmartDrive-demo/blob/master/SmartDrive.py)

 

 

I hope this works for you.

 

 

Have a nice day.

 

 

Regards,

 

-Leonardo

 

nDE_S
New Contributor I
248 Views

Hi -Leonardo,

I know you've been helping a lot.

To end this topic I would like you to help me to run smartteste.cxx in new edison with new image.

(in old edison it's run, With some erros, type: 1) in first start of the edison this code

var smart = require('jsupm_smartdrive');

var smarttest = smart.SmartDrive;

var smarttest = new smart.SmartDrive(0);

var teste = smarttest.GetBattVoltage();

setTimeout(function(){

smarttest.Run_Seconds(0x02,0x00, 90, 70, true, 0x01 );

console.log(teste);

setInterval(function(){

smarttest.StopMotor(0x02,0x02);

}, 4000);

}, 4000);

run motor 02 normally. But if I change code to 0x01 (motor 01) the code run motor 02 and motor 01 together. Before run only motor 01

with this code: https://github.com/intel-iot-devkit/upm/tree/master/src/smartdrive upm/src/smartdrive at master · intel-iot-devkit/upm · GitHub I can't run NEVER motor 01 or motor 02.

Then I stay transpose this codes of the old edison (https://github.com/neuberfran/SmartDriveold GitHub - neuberfran/SmartDriveold: esse sim ) to new, but in last moment I had these errors I've been trying to solve since the beginning of the day:

idata
Community Manager
248 Views

Hi Neuberfran,

 

 

You shouldn't compile or run any code that is here: https://github.com/intel-iot-devkit/upm/tree/master/src/smartdrive, all of them are the source codes that you need to compile your code.

 

 

Remember that you always need the source code ( https://github.com/intel-iot-devkit/upm/blob/master/src/smartdrive/smartdrive.cxx) and the header file ( https://github.com/intel-iot-devkit/upm/blob/master/src/smartdrive/smartdrive.hpp), to compile your code.

 

 

And did you try with 0x03 to see what happens?

 

 

Have a nice day.

 

 

Regards,

 

-Leonardo
nDE_S
New Contributor I
248 Views

Hi -Leonardo,

You did not understand my last question, but that's okay, I solved.

I was trying to run the old edison files in the new

Looking this : https://github.com/neuberfran/SmartDriveCorrect GitHub - neuberfran/SmartDriveCorrect and this https://github.com/intel-iot-devkit/upm/issues/461 Doing add-ons of the UPM sensor (smartdrive) to javascript and python · Issue # 461 · intel-iot-devkit/upm · GitHub

Now I need help of the @Propanu to change files. But that is not all. As I mentioned in my last post on this topic in the second run of this code: https://github.com/neuberfran/smartdriveexample/blob/master/teste5.js smartdriveexample/teste5.js at master · neuberfran/smartdriveexample · GitHub when I change 0x02 (motor 2) to 0x01 (motor 1) in this code: the motor 2 run 2 seconds (more or less). After the motors 2 and 1 runs together 5 seconds. And only then the motor 1 run only. And after everything is OK. I command node teste5.js and ONLY motor 1 run

I need help to change teste5.js code

idata
Community Manager
217 Views

Hi Neuberfran,

 

 

It is good to know that you solved it.

 

 

About the JavaScript code that only works with the motor 0x02, I tried my best to help you, but since I don't have the module I can't provide you useful suggestions to accomplish this. As a reminder this isn't an issue with Edison itself, it is a programming issue, so any changes or modification on custom codes rely on end users responsibility to make them work properly.

 

 

If you have another issues with the Edison, don't doubt to open another thread.

 

 

Regards,

 

-Leonardo
nDE_S
New Contributor I
217 Views

Hi -Leonardo,

I do this:

https://www.youtube.com/watch?v=fed8cvX1CrA Android things with intel edison - YouTube

I can't nothing about mraa and/or upm in this tutorial (used in this video): https://developer.android.com/things/training/first-device/create-studio-project.html Create an Android Things Project | Android Things

and I have a question:

Will I can use smartdrive/upm sensor with intel edison with Android Things?

Will I can use firebase in intel edison with Android Things?

(thanks

very)

idata
Community Manager
217 Views

Hi Neuberfran,

 

 

Nice video, good job. About your questions, I'm not sure about it.

 

 

Personally, I recommend you to try to contact Android or MRAA for more information about this issue.

 

 

Have a nice weekend.

 

 

Regards,

 

-Leonardo
Reply