Welcome Guest! To enable all features please Login or Register.
Options
Go to last post Go to first unread
Harrie  
#1 Posted : Saturday, July 28, 2018 11:29:56 PM(UTC)
Harrie

Rank: Newbie

Groups: Registered
Joined: 7/5/2018(UTC)
Posts: 9

Dear Embrio, Forum members

Problems Embrio 2.2.2.3
Operating system:
Windows 10, windows 7 on other computer same problem.
Software:
Arduino 1.8.5, Embrio 2.2.2.3
Hardware:
Arduino Uno R3, Stepper 28BYJ-48 5volt DC, board ULN2003 + external power supply 5 Volts / 1.2 Ampere.
With the program written in Arduino 1.8.5. the stepper motor operates normally, and the speed is adjustable.
Issue:
With the program written in Embrio, the speed of the stepper motor is not adjustable and is extremely slow by default.
Program Arduino - Arduino Uno:
Program made with Arduino 1.8.5, speed can be controlled with the command setSpeed (1000);
#include <AccelStepper.h>
#define HALFSTEP 8
// Motor pin definitions
#define motorPin1 3 // IN1 on the ULN2003 driver 1
#define motorPin2 4 // IN2 on the ULN2003 driver 1
#define motorPin3 5 // IN3 on the ULN2003 driver 1
#define motorPin4 6 // IN4 on the ULN2003 driver 1

// Initialize with pin sequence IN1-IN3-IN2-IN4 for using the AccelStepper with 28BYJ-48
AccelStepper stepper1 (HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4);

void setup () {
stepper1.setMaxSpeed (1000.0);
stepper1.setAcceleration (100.0);
stepper1.setSpeed (1000);
stepper1.moveTo (20000);

} // - (end setup) ---

void loop () {

// Change direction when the stepper reaches the target position
if (stepper1.distanceToGo () == 0) {
stepper1.moveTo (-stepper1.currentPosition ());
}
stepper1.run ();
}

Embrio:
Node: ULN2003 - stepper
With the above Node the speed of the stepper motor can not be varied
The standard speed is extremely slow, you can hardly see the engine moving.
In the Declarations sector of the node, the line _stepper.setSpeed (1000); added, it does not matter what value is entered, the speed does not change.
Also the Refresh rate in Embrio from 32 to 128, after this nothing happens anymore.

General:
In addition, I get at the closing of a project (after I have made a change in a node, as above).
It is also the case that when a new item is placed on the screen, it can not be moved. When Embrio is closed and restarted, these items can be moved.

Harrie
EmbrioAdmin  
#2 Posted : Sunday, July 29, 2018 6:34:12 AM(UTC)
EmbrioAdmin

Rank: Administration

Groups: Administrators
Joined: 12/11/2014(UTC)
Posts: 623

Thanks: 1 times
Was thanked: 36 time(s) in 33 post(s)
Hi,

Can you zip up your project folder and mail it to me at ezra@embrio.io? Not sure how to debug that issue without seeing the project.

What do you mean you get the closing the project when you make a change, does embrio crash?

The bug with the nodes not being able to move after adding a new one is really annoying, I thought I had that one figured out but I still occasionally get it too. I will continue to try to figure it out. In the mean time you can just close and reopen the agent that the node is on, you don't have to restart the whole program. How often are you getting this bug?
Harrie  
#3 Posted : Sunday, July 29, 2018 9:20:12 PM(UTC)
Harrie

Rank: Newbie

Groups: Registered
Joined: 7/5/2018(UTC)
Posts: 9

Thanks for the quick response

The project you have requested has been sent to your e-mail address in WinZIP format

What do you mean you get the closing the project when you make a change, does embrio crash?

Answer: what I mean is that when I change the refresh rate in e.g. 128, then there is no communication between Embrio and the Arduino uno. Embrio works well but no data.
When the refresh rate is reset to 32, the last action is executed and there is communication again.

The bug with the nodes not being able to move after adding a new one is really annoying, I thought I had that one figured out but I still occasionally get it too. I will continue to try to figure it out. In the mean time you can just close and reopen the agent that the node is on, you don't have to restart the whole program. How often are you getting this bug?
Answer: The problem occurs almost every time.
EmbrioAdmin  
#4 Posted : Monday, July 30, 2018 3:06:15 AM(UTC)
EmbrioAdmin

Rank: Administration

Groups: Administrators
Joined: 12/11/2014(UTC)
Posts: 623

Thanks: 1 times
Was thanked: 36 time(s) in 33 post(s)
Thanks for the info and sending me the project.

For this code the speed of the stepper is related to how often stepper.run() is called. In your Arduino code notice it is run very fast, the loop function seems to have no delay so stepper.run() gets called repeatedly until the movement is done. In the current Embrio project you have stepper.run() is only being called 32 times per second, thus the visibly slow movement.

You were right about changing the refresh rate. What you should do is make a new agent just for the stepper nodes and set that to something really high like 256 or even 512. Press the little icon next to the inputs or outputs that you want to access from your main control, then drag the new stepper agent onto the main control node screen.

When you change the refresh rate when you have an open connection you need to refresh the connection program, in the top right the little icon with the Embrio and Arduino icon's should have a "needs refresh" message, just click it again and a new program will be uploaded. The connection program has the "delay" timing hard coded into it so it needs to be updated when the refresh rate for a node changes.

Also note, when it comes to really fast timing like this, a compiled program works smoother than one in connection mode. When connected the Arduino sends data across the serial port to Embrio, which sends data back. It's enough to work out the logic in a program, but it does add a bit of slow down in the performance of the Arduino code. The little Up arrow in a micro chip icon in the top right of the screen uploads a final program. If you haven't already you can set up a free license on the site which allows you to do I think 5 uploads per month.

Let me know if that all works out for you.
Harrie  
#5 Posted : Monday, July 30, 2018 5:50:58 AM(UTC)
Harrie

Rank: Newbie

Groups: Registered
Joined: 7/5/2018(UTC)
Posts: 9

The two Stepper nodes removed from the agent.
Created a new agent and called this stepper.
Put the two stepper nodes in it and made the inputs and outputs available for other agents and set the refrash rate to 512.
The stepper agent was dragged to the other agent.
A node called stepper with the shared inputs and outputs is visible here.
This change does not work either when the refresh rate is set to a value other than 32 in the Stepper agent.
Embrio gives a Good connection and this does not change in refresh either.

What I had already tried is only to create a project with an agent with only a ULN2003 - stepper node and this only works with a refresh rate of 32.
EmbrioAdmin  
#6 Posted : Monday, July 30, 2018 4:51:57 PM(UTC)
EmbrioAdmin

Rank: Administration

Groups: Administrators
Joined: 12/11/2014(UTC)
Posts: 623

Thanks: 1 times
Was thanked: 36 time(s) in 33 post(s)
That's really strange I don't think the refresh rate should matter. I think I have a ULN somewhere I'll see if I can reproduce your issue.

When you say it isn't working, do you mean the motor isn't turning at all or just very slowly?
Harrie  
#7 Posted : Monday, July 30, 2018 8:53:50 PM(UTC)
Harrie

Rank: Newbie

Groups: Registered
Joined: 7/5/2018(UTC)
Posts: 9

When you say it isn't working, do you mean the motor isn't turning at all or just very slowly?

Answer: What I mean is that when the refresh rate is changed there is no output from the ULN2003 note (you will no longer see the remaining steps, it will remain zero).
No feedback from the uno
The engine is not running.
The engine only runs at a refresh rate of 32.
EmbrioAdmin  
#8 Posted : Tuesday, July 31, 2018 3:30:47 AM(UTC)
EmbrioAdmin

Rank: Administration

Groups: Administrators
Joined: 12/11/2014(UTC)
Posts: 623

Thanks: 1 times
Was thanked: 36 time(s) in 33 post(s)
It sounds like the connection program just needs to be refreshed. Do you see a "good connection" message in the top right of the screen? If so could you try adding something like a digital output node somewhere which will make it say "needs refresh" and then reupload a new connection program? Does that fix it or still no feedback from the motor node after that?
Harrie  
#9 Posted : Tuesday, July 31, 2018 9:12:39 PM(UTC)
Harrie

Rank: Newbie

Groups: Registered
Joined: 7/5/2018(UTC)
Posts: 9

A small update after the last program change yesterday, after the restart of the PC there is communication between Embrio and the Arduino uno. Only the speed of the engine is still slow (does not change).

As far as the connection is concerned, the good connection always lights up, so there is always a connection.
I check this by looking at the output of the uno after the LED, when it is lit up there is no communication or the LDR gives a value greater than 0.5 (a lot of light).

Conclusion: with the new stepper Agent set to a refresh rate of 512 the speed has not changed, and therefore still too slow.

What I also tried is Embrio and Arduino 1.8.5. installed on another PC with Windows 10 installed, and connected to it an Arduino Nano, here the problem is the same.
EmbrioAdmin  
#10 Posted : Thursday, August 02, 2018 5:53:43 PM(UTC)
EmbrioAdmin

Rank: Administration

Groups: Administrators
Joined: 12/11/2014(UTC)
Posts: 623

Thanks: 1 times
Was thanked: 36 time(s) in 33 post(s)
I hooked up my stepper and ULN2003 and am experiencing the same issue, the "steps left" value doesn't update any faster no matter what the refresh rate is. I'm still not sure what the problem is but I'll let you know as soon as it's figured out. Thanks for letting me know about this issue.
Harrie  
#11 Posted : Thursday, August 02, 2018 9:31:41 PM(UTC)
Harrie

Rank: Newbie

Groups: Registered
Joined: 7/5/2018(UTC)
Posts: 9

So much to thank you for your research work, I wait until you find a solution.
EmbrioAdmin  
#12 Posted : Saturday, August 04, 2018 11:44:55 AM(UTC)
EmbrioAdmin

Rank: Administration

Groups: Administrators
Joined: 12/11/2014(UTC)
Posts: 623

Thanks: 1 times
Was thanked: 36 time(s) in 33 post(s)
I got this figured out. I was able to fix it by changing the node, you'll have to restart Embrio and delete the node from your project then re-add it from the library. Make sure you click on the tab in the bottom left with the Embrio icon and delete the old node definition from your project before re-adding, or I think it'll still use the old version.

What I did was move the _stepper configuration from the Declarations section into the Startup section. I studied the compiled program and found that those lines were missing, I guess the Embrio code that does the parsing of the declarations section didn't like them so they were skipped. I guess that's also an incorrect place to put them, I tried putting those lines manually into the compiled program and got a compile error. Now that they are in the Startup section it works fine. Because those lines weren't there the "setAcceleration" and "setSpeed" functions weren't called so the stepper was configured to move very slow.

Thanks again for letting me know about the issue you had, this is a good limitation to know about.
Harrie  
#13 Posted : Sunday, August 05, 2018 12:56:09 AM(UTC)
Harrie

Rank: Newbie

Groups: Registered
Joined: 7/5/2018(UTC)
Posts: 9

Good thing you found the problem,

I have removed the stepper node 's from the project and in the bottom left window.
from the library copy the new uln2003 - stepper node and paste it into the node window as you have indicated.
A new node is now created, but only under the name "Embrio copy data", under the I / O tab a new node is created under the same name!.

When the "Embrio copy data" is dragged from the node tab to the agent screen, a node with the name ULN2003 - stepper appears.
The stepper node's placed in the stepper agent screen and leave the refresh rate at 512.
The project saved, the engine does not run under this refresh rate.
Refresh rate reset to 32 and now the engine is running, and also at a higher speed.
The engine can also be varied in speed.

Things are moving in the right direction, but the speed is still too slow.

The difference between the arduino program and Embrio is still too large.
EmbrioAdmin  
#14 Posted : Sunday, August 05, 2018 9:04:50 AM(UTC)
EmbrioAdmin

Rank: Administration

Groups: Administrators
Joined: 12/11/2014(UTC)
Posts: 623

Thanks: 1 times
Was thanked: 36 time(s) in 33 post(s)
I'm not sure I understand the first part, I can't reproduce that. No matter how I add the new ULN node to my project (either from the library tab or copying and pasting the xml from the site) the node gets added to the project node tab (the one with the Embrio icon). You are saying the new node definition shows up on the first tab in the bottom left?

Anyway as to the speed issue, it still has to do with how often _stepper.run() is called. I added a counter to the sample Arduino code you used and found that the loop runs around 90,000 times per second. In that program the loop runs as fast as possible because there is no delay() call like most programs would have.

To get the _stepper.run() to fire more frequently in the Embrio node I added a for loop around the chunk of code in the Every Update code. In my test I had it loop 1000 times. When I use that node on an agent refreshing at 512 the motor to my eye runs about as fast a it does in the example Arduino project. You could mess with the loop count i you want. I'm also not sure what the "half step" setting does, but I assume messing with that will effect the turn speed.

The edited node is below in the spoiler. Remove the node definition from your project and paste the below XML into a node screen, then you can mess with the loop counter in the Every Update section of the node. I might add another input to the library version of this node to control that, but would like to see your results first.

Harrie  
#15 Posted : Sunday, August 05, 2018 11:49:14 PM(UTC)
Harrie

Rank: Newbie

Groups: Registered
Joined: 7/5/2018(UTC)
Posts: 9

The way I’ve described the first part is probably due to a language barrier, I am Dutch and i use Google translate to translate my text, sorry for the confusion.

But the description in the first part is no problem, only something that struck me.

I copied the XML code into the node screen.

But now I get a compile error "'Input_Halfstep' was not declared in this scope”.

I’ve tried different values in the stepper node, but there’s no change.
With the old XML code there were no errors with compiling, there’s only a compiling issue with the new code.
EmbrioAdmin  
#16 Posted : Monday, August 06, 2018 4:21:11 PM(UTC)
EmbrioAdmin

Rank: Administration

Groups: Administrators
Joined: 12/11/2014(UTC)
Posts: 623

Thanks: 1 times
Was thanked: 36 time(s) in 33 post(s)
Oh yeah sorry about that. Open up the node and click the little gear icon next to the Half Step input. Inputs can't be accessed in the declaration code unless they are "configuration only". That's on the todo list to fix. In fact I think it's fixed on my local development copy which is why it was like that in the node I copied.
Harrie  
#17 Posted : Monday, August 06, 2018 9:26:42 PM(UTC)
Harrie

Rank: Newbie

Groups: Registered
Joined: 7/5/2018(UTC)
Posts: 9

The compilation is going well now.

The speed of the stepper motor seems to be fast enough, I have not measured any speed yet, but this is acceptable.
I want to thank you for your gigantic effort to solve my problem.

I will now continue to adjust the number of steps in the node (is now a maximum of 1000), and I have to go to about 10000.

Furthermore, I have noticed a few small bugs, I will make another topic for that when time comes.

I'm going to finish my project first, which I've been working on for more than a year.

Thank you very much for your time and effort.
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Notification

Icon
Error