New project programing questions.

Ok last time I tried this I got alot of additional support and ideas to change things… learning what I did on the last post I think this is a great way of brain storming. Would love to have some ideas if this will work I understand this is going to be complicated if even possible. but i want to try. This is the general
idea.

It’s a mobile over head crane using swerve drive. I’ve seen alot of posts about swerve drives and wanted to give it a try. So far the structure is complete and is strong and stable enough I am able to sit on the top and use it as a chair. If can easily lift a 25 pound weight and transport it. It lifts at about 1 inch per 45 seconds very slow but nessary. I’ve thought about how I would like to configure the code and tried to put it to paper before going to the actual coding process so there is some form of a guidline. That info will be posted next. It’s not a competition so I have no limits. Just something fun to do.

Device Listing

M1 - Left drive motor
M2 - Right drive motor
L1 - Lift motor
T1 - Trolley motor
S1 - Front left steer motor
S2 - Front right steer motor
S3 - Rear right steer motor
S4 - Rear left steer motor
P1 - Front left steer potentiometer
P2 - Front right steer potentiometer
P3 - Rear right steer potentiometer
P4 - Rear left steer potentiometer
LLS1 - Lift limit switch
TLS1 - Left trolley limit switch
TLS2 - Right trolley limit switch
LED1 - Drive configuration A selection
LED2 - Drive configuration B selection
LED3 - Drive configuration C selection
LED4 - Lift limit switch activation
LED5 - Left trolley limit switch activation
LED6 - Right trolley limit switch activation

Alternate device configuration option

*LED7 - Drive configuration D selection
*LED8 - Drive configuration E selection

Transmitter channels to be used.

Rx1 - Trolley Left / Right
Rx2 - Lift Up / Down
Rx3 - Drive Forward / Reverse
Rx4 - Not used
Rx5 - Drive option cycle up / down
Rx6 - Not used

Microcontroller ports to be used.

Motor 1 - L1
Motor 2 - T1
Motor 3 - M1
Motor 4 - M2
Motor 5 - S1
Motor 6 - S2
Motor 7 - S3
Motor 8 - S4
IO1 - P1 analog input
IO2 - P2 analog input
IO3 - P3 analog input
IO4 - P4 analog input
IO5 - LLS1 digital input
IO6 - TLS1 digital input
IO7 - TLS2 digital input
IO8 - LED1 digital output
IO9 - LED2 digital output
IO10 - LED3 digital output
IO11 - LED4 digital output
IO12 - LED5 digital output
IO13 - LED6 digital output
IO14 - LED7 digital output
IO15 - LED8 digital output
IO16 - Not used

Start loop
This part allows the user to press Rx5 “0” or “255” to cycle to programs and changes the LED’s to the appropriate status indication. Once the final program 5 has been selected reset back to 1. Also able to cycle backwards.

Program 1
This section is the default code drive pattern “A”. LED1 is illuminated.
S1, S2, S3, S4 move to the 0 degree position as specified by P1, P2, P3, P4 respectively.

1.	Rx1 moves the trolley left and right depending max limit switch input TLS1, TLS2. 
	If TLS1 is high then illuminate LED5 and only allow T1 to move opposite direction until TLS1 is low.
	If TLS2 is high then illuminate LED6 and only allow T1 to move opposite direction until TLS2 is low.
	If TLS1, TLS2 is low then allow T1 to move either direction. 

2.	Rx2 moves the lift up and down depending max upper limit switch input LLS1.
	If LLS1 is high then illuminate LED4 and only allow L1 to move opposite direction until LLS1 is low.
	If LLS1 is low then allow L1 to move either direction.

3.	Rx3 moves the drive motors forward / reverse.

Program 2
This section is the +90 degree drive pattern “B”. LED2 is illuminated.
S1, S2, S3, S4 move to the +90 (90) degree position as specified by P1, P2, P3, P4 respectively.

1.	Rx1 moves the trolley left and right depending max limit switch input TLS1, TLS2. 
	If TLS1 is high then illuminate LED5 and only allow T1 to move opposite direction until TLS1 is low.
	If TLS2 is high then illuminate LED6 and only allow T1 to move opposite direction until TLS2 is low.
	If TLS1, TLS2 is low then allow T1 to move either direction. 

2.	Rx2 moves the lift up and down depending max upper limit switch input LLS1.
	If LLS1 is high then illuminate LED4 and only allow L1 to move opposite direction until LLS1 is low.
	If LLS1 is low then allow L1 to move either direction.

3.	Rx3 moves the drive motors forward / reverse.

Program 3
This section is the -45 degree drive pattern “C”. LED3 is illuminated.
S1, S2, S3, S4 move to the -45 (315) degree position as specified by P1, P2, P3, P4 respectively.

1.	Rx1 moves the trolley left and right depending max limit switch input TLS1, TLS2. 
	If TLS1 is high then illuminate LED5 and only allow T1 to move opposite direction until TLS1 is low.
	If TLS2 is high then illuminate LED6 and only allow T1 to move opposite direction until TLS2 is low.
	If TLS1, TLS2 is low then allow T1 to move either direction. 

2.	Rx2 moves the lift up and down depending max upper limit switch input LLS1.
	If LLS1 is high then illuminate LED4 and only allow L1 to move opposite direction until LLS1 is low.
	If LLS1 is low then allow L1 to move either direction.

3.	Rx3 moves the drive motors forward / reverse.

Program 4
This section is the +45 degree drive pattern “D”. LED1, LED2 is illuminated (or LED7 depending configuration).
S1, S2, S3, S4 move to the +45 (45) degree position as specified by P1, P2, P3, P4 respectively.

1.	Rx1 moves the trolley left and right depending max limit switch input TLS1, TLS2. 
	If TLS1 is high then illuminate LED5 and only allow T1 to move opposite direction until TLS1 is low.
	If TLS2 is high then illuminate LED6 and only allow T1 to move opposite direction until TLS2 is low.
	If TLS1, TLS2 is low then allow T1 to move either direction. 

2.	Rx2 moves the lift up and down depending max upper limit switch input LLS1.
	If LLS1 is high then illuminate LED4 and only allow L1 to move opposite direction until LLS1 is low.
	If LLS1 is low then allow L1 to move either direction.

3.	Rx3 moves the drive motors forward / reverse.

Program 5
This section is the ±45 degree drive pattern “E”. LED2, LED3 is illuminated (or LED8 depending configuration).
S1, S3 move to the +45 (45) degree as specified by P1, P3 respectively.
S2, S4 move to the -45 (315) degree position as specified by P2, P4 respectively.

1.	Rx1 moves the trolley left and right depending max limit switch input TLS1, TLS2. 
	If TLS1 is high then illuminate LED5 and only allow T1 to move opposite direction until TLS1 is low.
	If TLS2 is high then illuminate LED6 and only allow T1 to move opposite direction until TLS2 is low.
	If TLS1, TLS2 is low then allow T1 to move either direction. 

2.	Rx2 moves the lift up and down depending max upper limit switch input LLS1.
	If LLS1 is high then illuminate LED4 and only allow L1 to move opposite direction until LLS1 is low.
	If LLS1 is low then allow L1 to move either direction.

3.	Rx3 moves the drive motors forward / reverse.

Drive patterns

http://i49.photobucket.com/albums/f291/immille/Swervedrive.jpg

WOW!!! You got pictures!!!

I am reading through your Specifications and it will take a little bit to visualize how you want to do this…

Expect feedback from me in a day or two…

MarkO

yeah learned alot from you last time trying to do more written planning because if you have a plan to follow it seems to help a great deal it breaks things down into smaller bytes :stuck_out_tongue:

http://www.youtube.com/watch?v=Dgal11srA64and video

I totally agree!!! You can go back and pieces and ideas as needed, until you have the basics worked out…

BTW, you have an awesome start on a Gantry Crane.

:slight_smile: going to be creating a stand today to get some rough numbers of the pots and motor rotations

So I got the stand created to test how the drive is going to work. Looks like I have lost 2 pots in moves so need to order another set… seems that the pots
have a range of 0 to 1015. so using the 1015 and knowing thats within 250 plus minus degrees of motion i can do some math now and start working numbers while i order 2 new pots and i’ve decided some new c-channels for a better version of mounting the wheels. so still got more work to do :slight_smile:

alrighty got 2 more pots ordered and another set of 1x5x35 c-channels so hoping that should finish it off. and I have a test rig set up it appears that the pot’s have 250 degrees of motion. so from what i can assume it’s 1 degree for every 4 increments roughly. must carry on…

carrying on… parts will be here tuesday yay! anyway starting to work on the actual programing. so i’ve configured the MC for the I/O’s and started to create the variables. I’ve created these variables in the GLOBAL area not sure if thats the right spot or if it should be in the variable area. but here they are.

int M1
Int M2
int L1
int T1
int S1
int S2
int S3
int S4
int P1
int P2
int P3
int P4
int LLS1 0
int TLS1 0
int TLS2 0
int LED1 0
int LED2 0
int LED3 0
int LED4 0
int LED5 0
int LED6 0
int LED7 0
int LED8 0

Here is updated V1.1 of the drafting process before actual coding… getting numbers squared away making sure things are labeled correctly and such eliminate confussing bugs durring codeing.

http://webpages.charter.net/idmiller/

Did a little bit more this evening with the coding. Let me explain the test bench
1 MC
1 battery
1 pot
1 motor
1 limit switch
1 led
1 84t gear attached to pot
1 12t gear attached to motor

So far I have got as far as when power up it finds the value of p1 and moves to the direction to center at 512. its’ really cute takes a few seconds due to the back lash of the gears and pot but it will keep trying to find center. i’ve tried the && and || to make it search and given it an acceptance range of 509 - 512 then stop. What I’m looking for it to do will be run this code only till it finds center then stop and go to the next loop and loop forever. because eventually there will be more code that will change it’s direction. Fairly happy that I’ve got this far on my own. going to keep plugging away at this and eventually i’ll figure out how to make it search find then continue. oh and on another note i’ve discovered this type of swerve drive is called omnidirectional as all four wheels rotate with their own motor. :slight_smile: more on the process to come. right now it’s sleep time.

YAY!!! 100% mechanical construction is complete still need about 12 more 2 foot jumper cables gonna need to order them can’t seem to find a happy medium to place the MC but I think I have a good location. The video shows a 25 pound weight yes 25 pounds. being transported across the trolley and being lowered completly then raised midway. Folled by a video of the gearing and motors. then moving to the swerve drive set up it’s non fuctional at the moment but it’s very stable. and yes a vex motor given the right gear ratio can lift 25 pounds.

I think the lifting and trolley part is about 4 mins and the rest of it is the gearing and other items. So understand this isn’t a very fast crane. thanks for checking it out. and I’ll keep updating the learning process for the coding. seems to be the biggest challenge so far.http://www.youtube.com/watch?v=WUI3Tay3rhA

I’ve learned alot in the last week. Seems like I’m going a little bit more complicated than what is needed. So this is the idea that I’m going to explore. we will call this version 2.0. Here’s what I’m going to explore. using function blocks and assignments for counts. 0 signal from rx5 will -1 on a counter and a 255 signal from rx5 will increase the count. Each drive setup will be a count of 1-5 so drive pattern “A” will have a count of 1 and it will run that function on power on. Keeping the same standard code for everything just calling upon a function when the count is added that it move the wheels in the direction of travel. Not 100% positive on if using functions is the way i want to go but might make the coding a bit more clean. will keep working out some options. going to have to update the code rough draft a bit.

also on a side note found a much more “fun” way to give me 360 degree unobstructed rotation but will require more work later. maybe that will be included on the next swerve drive in the future.

ID

new thought process on this V2.0. Still learning and trying to document the learning process. If you’ve done something similar to this feel free to toss out ideas and suggestions and what has worked for you.

Swerve Drive V2.0

Program starts
Turn off outputs 8, 9, 10, 11, 12, 13, 14, 15, 16, 17.
Calls function 1 sets wheels to neutral position.

Starts an infinite loop
1. Rx1 moves the trolley left and right depending max limit switch input TLS1, TLS2.
If TLS1 is high then illuminate LED5 and only allow T1 to move opposite direction until TLS1 is low.
If TLS2 is high then illuminate LED6 and only allow T1 to move opposite direction until TLS2 is low.
If TLS1, TLS2 is low then allow T1 to move either direction.

2.	Rx2 moves the lift up and down depending max upper limit switch input 			LLS1.
	If LLS1 is high then illuminate LED4 and only allow L1 to move opposite 		direction until LLS1 is low.
	If LLS1 is low then allow L1 to move either direction.

3.	Rx3 moves the drive motors forward / reverse.

4.	Rx5 gives signal to change "drive mode +1 or -1.
	Pending mode count calls "Drive Function 1-5"


Function 1
	Assigns the wheels to neutral position from inputs P1, P2, P3, P4.
	Turns output 8 on.
	Turns output 9, 10 off.
Function 2
	Assigns the wheels to +45 degree position from inputs P1, P2, P3, P4.
	Turns output 9 on.
	Turns output 8, 10 off.

Function 3
	Assigns the wheels to -45 degree position from inputs P1, P2, P3, P4.
	Turns output 10 on.
	Turns output 8, 9 off.

Function 4
	Assigns the wheels to 90 degree position from inputs P1, P2, P3, P4.
	Turns output 8, 9 on.
	Turns output 10 off.

Function 5
	Assigns the wheels to +-45 degree position from inputs P1, P2, P3, P4.
	Turns output 9, 10 on.
	Turns output 8 off.

Ok i’m stumped… How do i get an rx channel to do a single pulse.

I’m trying to cycle a program. but it’s cylcing way to fast i just want it to read the value one time

Get rx5 input

if rx5 is <= 128 then drive mode=1 but it keeps cycling through them all over and over… i’ll try to post some code tomorrow.

Add a wait command to it. IE:

if(input1 == 127)
{
DoSomethingHere;
wait1Msec(50);
}

(This is in robotC, don’t know about EasyC if that’s what you’re using - should be a similarly named command)

Ok so here is the test code… how do i keep it from cycling so fast and just go into a “step” mode. example i can push and hold rx5 0 and it only will cylce 1 time not keep cycling indefintally … no whammy no whammy no whammy

#include "Main.h"

void main ( void )
{
      // Place 3 Leds any color in D I/O 1, 2, 3 
      // Receiver pluged into RX1 on MC 
      SetDigitalOutput ( 1 , 1 ) ;
      SetDigitalOutput ( 2 , 1 ) ;
      SetDigitalOutput ( 3 , 1 ) ;
      while ( 1 == 1 )
      {
            Rx5 = GetRxInput ( 1 , 5 ) ;
            while ( 1 == 1 )
            {
                  if ( DriveMode == 1 )
                  {
                        SetDigitalOutput ( 1 , 0 ) ;
                        SetDigitalOutput ( 2 , 1 ) ;
                        SetDigitalOutput ( 3 , 1 ) ;
                  }
                  if ( DriveMode == 2 )
                  {
                        SetDigitalOutput ( 1 , 1 ) ;
                        SetDigitalOutput ( 2 , 0 ) ;
                        SetDigitalOutput ( 3 , 1 ) ;
                  }
                  if ( DriveMode == 3 )
                  {
                        SetDigitalOutput ( 1 , 1 ) ;
                        SetDigitalOutput ( 2 , 1 ) ;
                        SetDigitalOutput ( 3 , 0 ) ;
                  }
                  if ( DriveMode == 4 )
                  {
                        SetDigitalOutput ( 1 , 0 ) ;
                        SetDigitalOutput ( 2 , 0 ) ;
                        SetDigitalOutput ( 3 , 1 ) ;
                  }
                  if ( DriveMode == 5 )
                  {
                        SetDigitalOutput ( 1 , 1 ) ;
                        SetDigitalOutput ( 2 , 0 ) ;
                        SetDigitalOutput ( 3 , 0 ) ;
                  }
                  break ;
            }
            while ( DriveMode == 1 )
            {
                  if ( DriveMode == 1 && Rx5 <= 126 )
                  {
                        DriveMode = 5 ;
                  }
                  if ( DriveMode == 1 && Rx5 >= 128 )
                  {
                        DriveMode = 2 ;
                  }
                  break ;
            }
            while ( DriveMode == 2 )
            {
                  if ( DriveMode == 2 && Rx5 <= 126 )
                  {
                        DriveMode = 1 ;
                  }
                  if ( DriveMode == 2 && Rx5 >= 128 )
                  {
                        DriveMode = 3 ;
                  }
                  break ;
            }
            while ( DriveMode == 3 )
            {
                  if ( DriveMode == 3 && Rx5 <= 126 )
                  {
                        DriveMode = 2 ;
                  }
                  if ( DriveMode == 3 && Rx5 >= 128 )
                  {
                        DriveMode = 4 ;
                  }
                  break ;
            }
            while ( DriveMode == 4 )
            {
                  if ( DriveMode == 4 && Rx5 <= 126 )
                  {
                        DriveMode = 3 ;
                  }
                  if ( DriveMode == 4 && Rx5 >= 128 )
                  {
                        DriveMode = 5 ;
                  }
                  break ;
            }
            while ( DriveMode == 5 )
            {
                  if ( DriveMode == 5 && Rx5 <= 126 )
                  {
                        DriveMode = 4 ;
                  }
                  if ( DriveMode == 5 && Rx5 >= 128 )
                  {
                        DriveMode = 1 ;
                  }
                  break ;
            }
      }
}

I would also like to express the following.

  1. I’m still amature programmer
  2. I’m sure there is more efficent way of doing this.
  3. The final code that makes the unit work will be posted fully.

What I would like to see when the entire code is posted that the vex community take a look at it and tweak it and make it much more simple so it can be posted in the code section for others to download as a completed Omni Swerve Drive. The LIft and Trolley can be removed at that point so it is just drive patterns.

Thank you all for your support.