[SOLVED] S4/S5 enable

General discussion of using Roboclaw motor controllers
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: S4/S5 enable

Post by Basicmicro Support »

Once homing is enabled it is done automatically on power up. The home signals must be falling edge signals. If the unit powers up with the signals low it assumes the unit has the home sensor triggered. It will then move the motor forward until the signal releases(goes high). Then it will move backwards until it goes low again. At that point it also zeros the encoder count for that motor channel.

If the home signal is high then the motor just moves backwards until it triggers the sensor and zeros the encoder count.

Also the home movement(moving backwards) has a 5 second timeout.

You can confirm if your motor is wired for the correct direction of movement by testing with the PWM settings window of IonMotion. The motors should move forward when you slide the PWM slider up and backwards when you slide them down. If they dont, then reverse the motor wires.
GeeklyGrey
Posts: 42
Joined: Thu Oct 08, 2015 11:41 am
Re: S4/S5 enable

Post by GeeklyGrey »

Using IONmotion to check connections I find that a pair of wires connected to S3-gnd and S3-I/O are capable of making the status indicator for S3 go red when the other ends of the wires are touched together. Exactly as I expected it would.
Transfer the pair of wires to S4 or S5 and nothing happens. There is a setting for Homing (user) or Homing(auto). Neither options allow that pair of wires to do anything.

I have tried starting the motors using PWM or Velocity sections and then trying to get a reaction like a homing stop from the wires.
Is there a way of simulating the homing functions within IONmotion?

How do the Homing (user) or Homing(auto) features differ. I would have thought that the user version was just what I was trying to duplicate above? There is no info in the manual concerning these options.

I am hoping to be able to do two separate homing functions, M1 and M2, at a time and place of my own choosing, not necessarily on startup of RoboClaw. Physical constraints prevent movement at initial powering up of RoboClaw and other systems that will likely be powered up together.
GeeklyGrey
Posts: 42
Joined: Thu Oct 08, 2015 11:41 am
Re: S4/S5 enable

Post by GeeklyGrey »

Interesting..
I was having issues as described above where I was not getting --ANY-- response from touching some bridging wires across S4 or S5 I/O to the ground pin. IONmotion settings were on homing-user. S3 was on non-latching E-stop. S3 WOULD flash the device status indicator on as expected. Changed the setting to homing-auto and saved the settings to see what happened. S4,S5 Status indicators? Nothing.

On re-reading some of the earlier notes above I then decided to power-up roboclaw with one of the homing pins shorted to ground. Power on. Motor 1 started up in a negative direction and courtesy of the 5 second timer it then stopped. Okayyy... Noticed I had no USB connection, again. Bridged S4 again, Err light flicked and the second motor then started and ran for 5 seconds. Still no USB. Could not do anything with roboclaw until I eventually bridged S5. Makes some sort of sense. Noticed that the USB reconnected after this double homing stage after the second motor had done its thing.
USB disconnection for auto adjustment on start-up I can understand, and it does not seem to affect user setting that I would be using.

But now the S3 ERR pin does not respond to being bridged. I still seem to be able to flash the S4,S5 homing indicators in IONmotion but not S3. Changed setting back to homing-user on screen only -not saved. S3 now works and so do S4,S5
Saved the settings. S3 still works. Repowered roboclaw. S3 not working. Bridge S4 then S5. Still no S3.
Start one of the motors with PWM. S3 does not operate.
General Settings section is showing S3- E-stop, S4,S5 are on homing-user.
Change setting to homing-auto on screen. All S3,S4,S5 indicators now work.
Repowered roboclaw without bridging anything. Motor1 operated for a few seconds but S3 switch would not operate. Bridging S4 enabled motor2 to operate. Still no USB. Short S5 and USB comes back. Still no S3.
Reconnect IONmotion - still no S3. Change one of the settings to homing-user on screen - S3 now works.
Seems there is an error happening in here.

Conclusion
If you can follow that lot you may come to the same conclusion I did, that there is something not quite right with S3 vs Homing settings. S3 should ALWAYS work under ALL circumstances - it is the fail-safe switch circuit. These settings need to be predictable and reliable.

There was some initial register setting or lack of setting in roboclaw that prevented any homing activity in the first place and that may also be part of this problem.
And the other thing here is that NOW, -this-time-, while the setting was on homing-user - bridging S4 or S5 could now, finally, stop the motor and it would reset the counter to zero. Before the motor stopped moving. There always seems to be some small overrun on the counter which gets left there unless you zero the register again or provide an additional move back to the register zero position if the position is important enough.

Any observations on S3 vs homing or any of these notes?
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: S4/S5 enable

Post by Basicmicro Support »

The home function runs before the main loop. The USB autodetect runs in the main loop so no USB until the home has completed.

Ill look at S3. Its mode is set before the home functions execute. S3 should trigger(if set as an E-STOP). But I dont think I ever tested using an E-STOP while the auto homing was executing. I would suggest you use the manual homing option(where it does do the auto homing and then you can send packet serial commands to home the motor after startup.

Explanation of what happens when the home sensor is tripped:
When homing is enabled if the motor trips the home sensor(eg the signal goes low) the encoder will zero at that instant and the motor will be told to stop. The motor will not stop instantly though so the encoder will start to decrement from the new 0 point. You know know exactly where the motor is relative to the sensor even though it moved a bit past it.
GeeklyGrey
Posts: 42
Joined: Thu Oct 08, 2015 11:41 am
Re: S4/S5 enable

Post by GeeklyGrey »

Thanks for looking into this.

From my perspective, I started with 4.1.6, just before the update that brought in the button swap option. Then I seemed to be stuck on the wrong side of that change and could not make progress until the right bit of fiddling got me past that.
Then this area of S4,S5 seems to have been similar. I had S3 but no S4,S5. And that seems to be alternating with S4,S5 but no S3, partly affected by homing setting chosen.

Perhaps a look at the affected registers or memory spaces is needed together with pre-initialisation of newly claimed spaces for new features, as they are added, in order to safely bring existing users into alignment along with the new changes.
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: S4/S5 enable

Post by Basicmicro Support »

I looked at the code and E-STOP is checked before everthing else. Are you using latched or un-latched E-STOP? If E-STOP is triggered the motors should stop no matter what even if the homing routine is running. I'll have to wire it up and test it to see if Im missing something.

The S4 and S5 pins(and registers) were unused on the older boards without those pin headers. The pins were just not connected to anything. Otherwise the older boards are functionally identical to the new ones.

S3 however has a fairly complex logic to it since it can, by default, be E-STOP(latched or not, when in packet serial mode) or it can be over ridden when in packet serial mode to be an output to control an external voltage clamp, but when in RC/Analog modes it is a flip switch control always(all other options are disabled for S3 in those modes).

The auto homing on power up was added primarily so people using RC or Analog modes could still use incremental encoders in position mode instead of just absolute enocers.

The manual homing mode is what I would recommend be used if you are using a micro with packet serial commands to talk to the roboclaw. Then the procedure would be to:

1. Check the home signal status bits.
2. If it is triggered move the motor forward until it isnt triggered or some timeout happens.
3. Move the motor back to the sensor until the home signal triggers(motor will automatically stop).
4. Repeat steps for motor 2.

Doing it manully lets you use the velocity commands where the autohome just uses a preset PWM power %.
GeeklyGrey
Posts: 42
Joined: Thu Oct 08, 2015 11:41 am
Re: S4/S5 enable

Post by GeeklyGrey »

My intention is to continue using E-stop in the un-latched mode. I was only changing over to latch mode briefly because that action happens to make S3 work again.

I am stepping through some checks now as I write.
Power on to RoboClaw, one of the motors kicked and stopped-not sure which one. Encoder readouts are zero.
IONmotion - General settings shows S3 - E-stop, S4 and S5 are both on Home(user).

Check the device status response to bridging contacts
S3- no reaction at all
S4- indicator flashes yellow -also ERR flash red
S5- indicator flashes yellow -also ERR flash red

Click on Velocity panel - make a small move with a motor. S3 not working.
I clicked on Device - read settings -S3 now works, also S4 and S5 - Why? don't know.
Assume Read settings is reading from Roboclaw - not from computer file somewhere.
So if reading Roboclaw makes it work why does it not work on powering up.

Power off again. Power on. S3 not working. Check S4,S5 working - S3 still not working. Connect to IONmotion- S3 still not working. Small move with Velocity screen- S3 not working. Zero encoders to neutralise test movements.

What will make S3 work? I know that fiddling with Homing setting does.

Change setting of S5 to homing(auto) - S3 now works - change setting back to Homing(user)- S3,S4,S5 are working. If I save the settings now will it stick? Try it. Saved settings. Disconnect IONmotion, power off RoboClaw. Wait for 10. Power on. No S3. S4 and S5 ok. No motor movements.

So the working situation when connected to IONmotion did not save or does not occur on re-powering.

Is there anything else you would like me to try?
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: S4/S5 enable

Post by Basicmicro Support »

Ok. You haev S4/S5 set to Home(user) which means the roboclaw will only stop the motors when it sees a falling edge on the signal input(M1 for S4 and M2 for S5).

Try to narrow down what is happening with the motor kicking when powering up. Is the home signal triggered or not? This could indicate some kind of glitch on the signal input during powerup.

Read settings reloads the settings from NVM(eeprom). That would indicate something is changing the S3 setting between powerup and the point you read settings. Also changing other settings in IonMotion causes all settings to be updated, eg we have a single subroutine in IonMotion that sends all the current settings to the roboclaw when you change any one setting. So it appears either forcing a reloading of settings from eeprom or reloading manually(eg by IonMotion sending all the settings to the Roboclaw) brings S3 back to life.

Atleast that would narrow down what Im looking for and when in the code it has to be. if you think of anything else that could be causing that effect let me know.

One other test, does S3 work fine on power up if you are not using S4/S5 as home inputs?
GeeklyGrey
Posts: 42
Joined: Thu Oct 08, 2015 11:41 am
Re: S4/S5 enable

Post by GeeklyGrey »

The motor did not kick this morning on power up, think that motor kick is not an issue, does not usually do that. In fact I just switched it off and back on again five times and not a peep from the motors.
I had left the settings on Home(user) since our last contact so would not expect a self homing activity.
The S3 is currently not working, I have IONmotion on screen and now connected. Have done nothing on screen as yet.
S4 and S5 still can flash the ERR light meaning they would work if needed. Settings are still S3-Enable, S4,S5 Home(User).
PWM page has no settings on it, Velocity settings page just has QPPS = 2000, Position settings page has QPPS=2000, Velocity PID = 0,0,0 Position PID = 10000, 2, 200, MaxI=5, MaxPos=2000. I am running a bare shaft setup at present until I install the motors and can do a proper tune-up. Motors are Hiwin -AM3 DC brushed gearmotors with encoders giving about 980 pulses/rev or 3920 quad edges per rev. Accel/decel settings=3000.
I was looking around IONmotion looking to see what I could do without actually changing the S3 problem, but there are not many options. Look at Device Status, Look at General Settings, Move motors under PWM, Move motors under Velocity settings, No change to S3.
Then I put in some values, 3000,3000,2000 under accel, decel, speed and made a little move under Position settings and the S3 came to life.
So I saved the settings again. powered off, power on again and S3 not working.

I was going to copy the General Settings Page and paste it here but it seems I am not able to get a copy of it using the Alt-PrtScrn or Cntrl-P options. (Perhaps an entry under the help tab to facilitate getting screen shots could be useful here.) However, there does not seem to be anything much to report on.

I also just did another update - because I could - and that did not change the S3 situation- still not working. Seems that does not clear or prepare any relevant memory spaces.

And a reminder that in the earlier stages of my roboclaw experience I could get S3 but no way would S4,S5 work. Seems there is a common thread of some sort there, in an Either/Or sense. one or other but not both.

Is there any way of getting a ram dump from roboclaw? might be useful.
I will assist where I can.
GeeklyGrey
Posts: 42
Joined: Thu Oct 08, 2015 11:41 am
Re: S4/S5 enable

Post by GeeklyGrey »

First, in my previous reply I missed your last question about disabling S4/S5 and to try powering up, check S3.
Result is that S4/S5 is not working and neither is S3. Powered up and checked S3,S4,S5, nothing. Then connected IONmotion and still nothing.
Clicking Device/'Read Settings' can make S3 operate. That is a very basic action and would not be writing anything except the 'port and command' formatted structure into roboclaw and yet the end result is that it works. That has got to trackable in code somehow.

From notes above, Roboclaw starts up with whatever processes you use, and S3 is currently not working.
Then S3 remains inactive until a simple read (or write) action writes 'something' TO roboclaw, or writes something within roboclaw, making S3 active.

That 'something' apparently does not get written to eeprom/flash ram .. whatever storage is used, with any save action, just written to roboclaw volatile memory, even if 'Save settings' is clicked.
So when the roboclaw is powered up that 'something' is not present where it is needed and not loaded from eeprom and so S3 is not functioning again. So the assumption to draw here is that something in the S3 code is testing for a value that is held in volatile memory and that value does not get saved, restored or initialised.

Two areas to consider present themselves to me.
1 Monitor - everything- that roboclaw needs to do to achieve say, S5 setting change between 'Home(user)' and 'Disabled'. This is probably a far simpler command to follow than the next one.
2 Monitor - everything- that roboclaw needs to do to achieve the 'Read Settings' as described above.
There is probably some common ground between those two tasks and something there is a trigger.
Once S3 is activated it stays going until the next power up action when it fails again.

Post Reply