using S3 & S4 as home switches
-
- Posts: 32
- Joined: Fri Jan 29, 2016 4:00 pm
using S3 & S4 as home switches
Can you explain a little more about how this works? If I have them tied to my home microswitches, what command would I issue (packet serial) to tell it to go home. Does it have accel/decel? Thanks.
- Basicmicro Support
- Posts: 1594
- Joined: Thu Feb 26, 2015 9:45 pm
Re: using S3 & S4 as home switches
Im assuming you have the signals set to Home(user). This means you have to manually move the motors till they trigger the home switched after power up. To do this you just use any movement commands you want to. if you use a Distance command just make sure you give a distance that is gaurunteed to get the motor back to the home switch. If you use a position command remember that the encoder will start at 0 so give a it a positon(some negative value) that is far enough back to gauruntee it will trigger the home switch. You can use commands with acceleration settings or not.
When the switch triggers the motor will be stopped automatically and the encoder for that motor will be reset to 0.
When the switch triggers the motor will be stopped automatically and the encoder for that motor will be reset to 0.
-
- Posts: 32
- Joined: Fri Jan 29, 2016 4:00 pm
Re: using S3 & S4 as home switches
That sounds great. It should be easy to use that feature then.
So this arduino code would send the motor to the home position:
Am I correct that once the home switch is triggered, the buffer will empty? Also, will the roboclaw hold the 0 encoder position? Like if it overshoots home, from the time the switch triggers to the time the motor stops will it try to take the motor back to the 0 encoder mark?
So this arduino code would send the motor to the home position:
Code: Select all
boolean returnM1Home() { //returns true if successful
roboclaw.SpeedAccelDeccelPositionM1(address, accel, maxSpeed, deccel, -3000000, 0); //2500000 pulses is the max table length
uint8_t depth1; //buffer 1 reading
uint8_t depth2; //buffer 2 reading
while (1) { //wait for buffers to be empty
roboclaw.ReadBuffers(address, depth1, depth2);
if (depth1 == 0X80 && depth2 == 0X80) return true;
delay(300);
} //end of waiting for drillhead position
}
- Basicmicro Support
- Posts: 1594
- Joined: Thu Feb 26, 2015 9:45 pm
Re: using S3 & S4 as home switches
Once the home switch triggers the movement command will be finished. However only that command will be removed from the buffer IIRC. So if you sent a home command(eg move -30000000) and a command to move forward 10000 it should move backwards until the home sensor triggers and then execute the 10000 move forwards.
-
- Posts: 32
- Joined: Fri Jan 29, 2016 4:00 pm
Re: using S3 & S4 as home switches
Thanks. It's going to be great having the roboclaw monitor the home microswitch, and I'll also set up the Out Of Bounds microswitches to, so my atmega chip would have to bother watching them.
Cheers.
Cheers.
- Basicmicro Support
- Posts: 1594
- Joined: Thu Feb 26, 2015 9:45 pm
Re: using S3 & S4 as home switches
One correction. The S4 and S5 pins are available for home signals. Not S3. I just re-read the tital of the post and realised that.
Re: using S3 & S4 as home switches
Is for position a negative value allowed?SouthernAtHeart wrote: roboclaw.SpeedAccelDeccelPositionM1(address, accel, maxSpeed, deccel, -3000000, 0); //2500000 pulses is the max table length
- Basicmicro Support
- Posts: 1594
- Joined: Thu Feb 26, 2015 9:45 pm
Re: using S3 & S4 as home switches
Yes. If you set the Min Position setting to a negative value you can set negative positions. Min and Max Position settings set the available range limits for the Position commands.