Octave-Arduino-Servo

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Octave-Arduino-Servo

Vicent
Hi,everyone.
 I'm trying to control a sd90 servo with arduino using octave, but I don't
now what I'm missing.
I have octave 4.2.2 in Ubuntu.   arduino 1.8.6 but not installed only
downloaded but it works well
package octave- arduino 0.3.0 instrument-control 0.3.1

I can detect the arduino and put digitals pins to on or off but when I try
to use the servo I only get error messages. I don't know why I can't
initialize the servo object.
This is my testing program and the result in command window:

#testing program arduino-servo
1  pkg load arduino
2  
3  ar = arduino("/dev/ttyACM0","Uno","Libraries","servo")
4
5  % get the pin names
6  pins = ar.availablepins;
7  writeDigitalPin (ar,  "d13", true);
8  #pause (2)
9  value1 = readDigitalPin (ar,  "d13")
10 writeDigitalPin (ar,  "d13", false);
11 #pause (2)
12 value2 = readDigitalPin (ar,  "d13")
13 value3 = readVoltage (ar,  "a0")
14
15 myServo = servo(ar, "d9", "minpulseduration", 1.0e-3,
"maxpulseduration", 2e-3);
16
17 writePosition (myServo, 0.5);

----------
Result on Command Window
>> provaArduino

ar =
  arduino object with fields of:
    port = /dev/ttyACM0
    board = uno
    libraries = {
      servo
    }
    availablepins = {
      d0 - d13
      a0 - a5
    }
value1 =  1
value2 = 0
value3 =  2.4536
error: sendCommand: failed err=10: msg=Unknown cmdID
error: called from
    sendCommand at line 72 column 5
    servo at line 119 column 3
    provaArduino at line 15 column 9
>>
-------
Thanks for your help



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: Octave-Arduino-Servo

Andreas Weber-6
Am 28.11.18 um 23:14 schrieb Vicent:
> error: sendCommand: failed err=10: msg=Unknown cmdID

Hi Vincent,
I never used the package but from the errormessage I guess the firmware
on the arduino doesn't know the servo command. Have you run
"arduinosetup" before (which falshes the firmware to the AVR)?

-- Andy


Reply | Threaded
Open this post in threaded view
|

Re: Octave-Arduino-Servo

Vicent
Yes but I didn't do correctly because Octave didn't found my 1.8.6 arduino
binary program but it found the (2:1.0.5 +dfsg2-4.1) arduino  version from
the ubuntu repository that I guess it's outdatet. Then I copied and pasted
the arduinosetup program from the old IDE to  the 1.8.6  and I uploaded the 
arduinosetup program to the arduino board but  seems that it didn't work
properly.
Now I have the same problem, Octave is not able to find the arduino binary
when I run the arduinosetup (I deleted the old version of arduino) This is
what I get in the command window.
>> pkg load arduino
>> arduinosetup
error: __arduino_binary__: can not find the arduino binary
error: called from
    __arduino_binary__>find_arduino_binary at line 75 column 5
    __arduino_binary__ at line 26 column 22
    arduinosetup at line 188 column 21

I've copied manually the arduino file from the arduino-1.8.6 folder to the
/usr/bin/ folder and then, after reopen octave  I've got this:

>> pkg load arduino
>> arduinosetup
Picked up JAVA_TOOL_OPTIONS:
Error: Could not find or load main class processing.app.Base
Running "/usr/bin/arduino" "/tmp/oct-Rsy4gf/octave/octave.ino"
ans = 0
>>
I don't know what can i do...
Thanks for your patience.



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: Octave-Arduino-Servo

Vicent
This post was updated on .

Hello again,
Fortunately, the communication problem has been solved  with the help of
John Donoghue  who said me to use this:
arduinosetup ('arduinobinary', '/the_path_to_it/arduino')

and it works!
But  I'm having still problems with this because the servo works very well
when it runs from the arduino IDE but it doesn't move when I try to do it
using the previous Octave program.
In the Command windows everything appears to be correct without error
messages.
-----------------------------------------
ar = arduino("/dev/ttyACM0","Uno","Libraries","servo")
myServo = servo(ar, "d9", "minpulseduration", 1.0e-3,  "maxpulseduration",
2e-3);

writePosition (myServo, 0);
position = readPosition (myServo)
pause(1);
writePosition (myServo, 1);
position = readPosition (myServo)
----------------------------------------------

I've checked that the minimum pulse and maximum pulse duration are correct.
It's a sd90 servo. I know that the period is 50Hz (20 ms) but I don't know
how to configure to the program, I guess it's not necessary to do it . I
have not found more information about this.
 Thanks for your patience again.



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: Octave-Arduino-Servo

Vicent
Now I've been able to move the servo, but I'm receiving an error message and
I have to restart the arduino board every time, disconnecting the USB cable.
If I press the reset arduino button, it doesn't work.

The error message appears when the servo is defined. After that I have to
disconnect it again.

-----
a=10
ar = arduino();
b=20
myServo = servo(ar, "d9", "minpulseduration", 1.0e-3,  "maxpulseduration",
2.0e-3);
c=30
writePosition (myServo, 0);
d=40
position = readPosition (myServo)
pause(2);
writePosition (myServo, 1);
position = readPosition (myServo)
---------
>> provaArduino3

a =  10
b =  20
warning: onCleanup: error caught while executing cleanup function:
srl_timeout: error setting timeout...
c =  30
d =  40
position = 0
position =  1
______

If I don't disconnect the board It doesn't work and I don't recieve the
error message.

>> provaArduino3

a =  10
b =  20
c =  30
d =  40
position = 0
position =  1



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: Octave-Arduino-Servo

John Donoghue-3
In reply to this post by Vicent
On 12/1/18 8:04 AM, Vicent Borras wrote:
Thank you very much again. I've been able to move the servo!!
 But I'm receiving an error message and I have to restart the arduino board every time, disconnecting the USB cable.  If I press the reset arduino button, it doesn't work.
It works once and  I receive an error message when the servo is defined. After that I have to disconnect it again.
It's the same doing small or big movements.
-----
a=10
ar = arduino();
b=20
myServo = servo(ar, "d9", "minpulseduration", 1.0e-3,  "maxpulseduration", 2.0e-3);
c=30
writePosition (myServo, 0);
d=40
position = readPosition (myServo)
pause(2);
writePosition (myServo, 1);
position = readPosition (myServo)
---------
>> provaArduino3

a =  10
b =  20
warning: onCleanup: error caught while executing cleanup function:
srl_timeout: error setting timeout...
c =  30
d =  40
position = 0
position =  1
______
If I don't disconnect the board It doesn't work and I don't recieve the error message.
>> provaArduino3

a =  10
b =  20
c =  30
d =  40
position = 0
position =  1





Disconnecting the board will put it out of sync in terms of any configuration it has done on the board, so perhaps isnt surprising that it shows an error at the case.


Modify your code to:


a=10
ar = arduino();
b=20
myServo = servo(ar, "d9", "minpulseduration", 1.0e-3,  "maxpulseduration", 2.0e-3);
c=30
writePosition (myServo, .5);
d=40
position = readPosition (myServo)
pause(2);
writePosition (myServo, .8);
position = readPosition (myServo)



And try it - I am still thinking you are possibly having issues from drawing too much power with the servo with the large movements and causing the board to reset.





Reply | Threaded
Open this post in threaded view
|

Re: Octave-Arduino-Servo

John Donoghue-3
On 12/1/18 11:36 AM, Vicent Borras wrote:
> so your previos program with steps on movement of 0.02 and I've got
> the same result, the error message and the need of disconnect it to
> run it again. Maybe the err


Just to be clear.
Starting with the arduino plugged in, NOT running octave.

Run octave and then execute the the step program once only.


 > provaArduino3


Does it show the error, does it move the servo. Can you provide full
output ?


Without disconnecting the arduino, run


 > clear all


Then rerun the step program

 > provaArduino3


What does it do ? Can provide full output.






Reply | Threaded
Open this post in threaded view
|

Re: Octave-Arduino-Servo

John Donoghue-3
On 12/1/18 4:11 PM, Vicent Borras wrote:
Hi John,
I've done as you've said.
When I run the first time there is no error message and the servo works well.
Then I typed "clear all" and worked well again but showing two warnigs.
After that I tried to run the program without "clear all" and the servo didn't work and I didn't got error or warnings messages.
Finally I typed "clear all" and worked well showing the warnings.
I'm sending all the output.
Thanks again

a=10
ar = arduino();

b=20
myServo = servo(ar, "d9", "minpulseduration", 1.0e-3,  "maxpulseduration", 2.0e-3)
c=30
writePosition (myServo, .5);
d=40
position = readPosition (myServo)

speed = 0.02;

for count = (1:150)

   pos = readPosition (myServo);

  pos = pos + speed;

   if(pos > 1)

      pos = 1;

      speed = -speed;

    endif

    if(pos < 0)

      pos = 0;

      speed = -speed;

    endif

   writePosition (myServo, pos);

   pause(0.1);

endfor
___________________________________________________
GNU Octave, version 4.2.2
Copyright (C) 2018 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type 'warranty'.

Octave was configured for "x86_64-pc-linux-gnu".

Additional information about Octave is available at http://www.octave.org.

Please contribute if you find this software useful.
For more information, visit http://www.octave.org/get-involved.html

Read http://www.octave.org/bugs.html to learn how to submit bug reports.
For information about changes from previous versions, type 'news'.

>> pkg load arduino
>> provaArduino3    HERE WORKED WELL

a =  10
b =  20
myServo =
  arduino servo object with fields of:

                pins = d9
    minpulseduration = 0.001000
    maxpulseduration = 0.002000
c =  30
d =  40
position =  0.50000
>> clear all
>> provaArduino3     HERE WORKED WELL
a =  10
warning: duplicate binary operator '==' for types 'octave_serial' and 'octave_serial'
warning: duplicate binary operator '!=' for types 'octave_serial' and 'octave_serial'
b =  20
myServo =
  arduino servo object with fields of:

                pins = d9
    minpulseduration = 0.001000
    maxpulseduration = 0.002000
c =  30
d =  40
position =  0.50000
>> provaArduino3    HERE DIDN'T WORK
a =  10
b =  20
myServo =
  arduino servo object with fields of:

                pins = d9
    minpulseduration = 0.001000
    maxpulseduration = 0.002000
c =  30
d =  40
position =  0.50000
>> clear all
>> provaArduino3   HERE WORKED AGAIN
a =  10
warning: duplicate binary operator '==' for types 'octave_serial' and 'octave_serial'
warning: duplicate binary operator '!=' for types 'octave_serial' and 'octave_serial'
b =  20
myServo =
  arduino servo object with fields of:

                pins = d9
    minpulseduration = 0.001000
    maxpulseduration = 0.002000
c =  30
d =  40
position =  0.50000
>>

Missatge de John Donoghue <[hidden email]> del dia ds., 1 de des. 2018 a les 21:08:
On 12/1/18 11:36 AM, Vicent Borras wrote:
> so your previos program with steps on movement of 0.02 and I've got
> the same result, the error message and the need of disconnect it to
> run it again. Maybe the err


Just to be clear.
Starting with the arduino plugged in, NOT running octave.

Run octave and then execute the the step program once only.


 > provaArduino3


Does it show the error, does it move the servo. Can you provide full
output ?


Without disconnecting the arduino, run


 > clear all


Then rerun the step program

 > provaArduino3


What does it do ? Can provide full output.




ok - no errors printed when it didnt work ?

After running the script, are the servo and arduino objects in the variable window?

If so, thats the main issue - as the hardware is already allocated from the original calls, but doesnt check whethers ats already allocated on the second call.


the clear all clears all the variables and so frees the objects, so then allows them to be recreated correctly gain.





Reply | Threaded
Open this post in threaded view
|

Re: Octave-Arduino-Servo

Vicent
This post was updated on .
John Donoghue-3 wrote
> ok - no errors printed when it didnt work ?
>
> After running the script, are the servo and arduino objects in the
> variable window?
>
> If so, thats the main issue - as the hardware is already allocated from
> the original calls, but doesnt check whethers ats already allocated on
> the second call.
>
>
> the clear all clears all the variables and so frees the objects, so then
> allows them to be recreated correctly gain.

No errors printed when it didn't work , and after running the script the
servo and arduino objects are in the variable window.
So using 'clear all' solve this and allows to run very well, there are only two warnings in the Command editor but it's working well.

warning: duplicate binary operator '==' for types 'octave_serial' and 'octave_serial'
warning: duplicate binary operator '!=' for types 'octave_serial' and 'octave_serial'






--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: Octave-Arduino-Servo

John Donoghue-3
In reply to this post by Vicent
On 12/2/18 9:56 AM, [hidden email] wrote:

> Hi!
> Thank you very much for solve this problem , your patience and time.
> Now it works very well!
>
> I have another issue but I'm not sure to use this thread.
> 1) All we have been doing it has been in my desktop pc, I've also tried to do it  in my  laptop and I'm able to use the ardunosetup instruction to load the software to the board but after close the arduino IDE when I use the scanForArduinos instruction the result is this:
> ans = {}(0x0)
> Should I open other thread?
>
> Finally I've also seen that in my sd90 servo using
>   "minpulseduration": 1.0e-3  and  "maxpulseduration": 2.0e-3, the angular displacement is about 90 degrees whereas if I change them to "minpulseduration": 0.54e-3 and  "maxpulseduration": 2.43e-3 the result is a possible angular displacement of 165 degrees. The weird thing is that the sd90 datasheet  says that between 1.0e-3 and 2.0e-3 the displacement has to be of  180 degrees. Maybe is a particular servo issue and it's not a problem to deal with it.
> Thanks again.
>
> _____________________________________
> Sent from http://octave.1599824.n4.nabble.com
>
>
Sometimes It may take a little while for the USB port to be available,
so may not show up. If you run the scan again does it show up?


You should really only need to run arduinosetup once (unless updating,
to compiling with additional libraries/addons)

Looking up the SG-90, I see several complaints about the range of them
not being between -90 - 90  for the 1 - 2ms input




[1] https://servodatabase.com/servo/towerpro/sg90




Reply | Threaded
Open this post in threaded view
|

Re: Octave-Arduino-Servo

Vicent
John Donoghue-3 wrote

> Sometimes It may take a little while for the USB port to be available,
> so may not show up. If you run the scan again does it show up?
>
> You should really only need to run arduinosetup once (unless updating,
> to compiling with additional libraries/addons)
>
> Looking up the SG-90, I see several complaints about the range of them
> not being between -90 - 90  for the 1 - 2ms input
>
> [1] https://servodatabase.com/servo/towerpro/sg90

I 'm getting the same result every time, now I've been waiting 45 minutes
and I got the same:
ans = {}(0x0)




--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html