Cnc Shield Joystick

0 views
Skip to first unread message

Brittany Bhadd

unread,
Aug 4, 2024, 12:56:43 PM8/4/24
to teisnowtito
Irecently purchased an Arduino Uno R3 board with a Arduino Motor Shield Rev3 as well as a joystick breakout board. My aim is to use the thumb joystick to control the direction of the stepper motor on the X-axis, left to right as well as the speed. So far I've been looking for good tutorials on the net with regards to the subject but had no luck so far.

Attached to this article are two photos showing how I connected my joystick to the motor shield board as well as a closeup view of the specific joystick I bought. Here is a link to the joystick as well:


Below is some sample code I downloaded from the net which rotates the shaft from one direction to the other with a delay. How can I modify this code to work with my setup and control the motor via the joystick:


could you give more info on how exactly you one to control the motor with the joystick.

what i mean is what does pushing the joystick to the right do to the motor and what know, please explain so we could help you more


Well, when the joystick is in the center and not moving, the motor shouldn't do anything and stop. When the joystick is pressed to the left or right, the motor must move in the respective direction and the further the joystick moves from the center, the faster the speed of the motor must be. So basically left and right movement via the joystick as well as speed adjusting as the joystick moves further from the center pin.


The purpose of this setup is to slide a camera left and right, faster and slower on a rail of plus minus 1.5m in length. Attached to the stepper motor's shaft will be a pulley and on the other side just a normal shaft enclosed in a bearing unit also containing a pulley. I'll then use timing belt to slide the camera left and right.


I'm really not very clued up with prototyping and therefore if you can help me to amend the code to work with my setup, I'll really be happy since I've been battling and struggling to get the project going. But looking at my connection setup, is everything connected to the right pins etc?


well what you need to do is to divide the value of a pot into half

so i would say that 507 until 517 is a good middle value.

then take the value between 517 until 1023 and map it with the min and max of the stepper speed.

after that take between 0 to 507 value of pot n map it with the min n max of the stepper speed.

third is that determine which side of the pot make the stepper move clockwise. what i give here should give you an idea on how to do it


In theory I know what you're saying and it makes sense to me. However, how can I practically amend this code and incorporate everything that you have said? I'm not a code guru and this is all new to me.


this part is the part which dictate how much step the stepper would take to complete a rotation.

i would recommend to you to put the total number of step it take for your set up form its start position on the far left to the far right or vice versa. How ever this is not something that is really must needed and you could actually make it variable.... maybe by making use of the other axis of your joystick?


this is the part that call for the speed of how fast the stepper rotate.

if my understanding of your project is correct, this part need to be implemented in the loop function and now the setup function cause it need to be variable. However before you impliment any of the changes that i suggest, i would recommend that you play with the value 75 that is in the code with something that is higher up until the point your motor stall. This would mean, that the value you got there is the max speed that the stepper could go. one more thing is would also suggest that you do this with the full load of your setup. this is to make sure that you get the most accurate value for your setup and not just something that is calculated or theoretical.


Btw i would also like to suggest to you that, you pun 2 home sensor, this could be a simple limit switch or the type that use light sensor to detect your carriage on both end of the travel. this would help if let say your carriage at it end but you keep giving it the signal to go forward. although for a stepper this will not cause lots of trouble since if the motor will stall if it cant move the carriage but it might or could shorten the life of the motor... so putting the sensor will save it n give the motor a much longer life and reliability


I had a few trials and errors so far. I eventually got the setup going with the code you provided as well as other code I found. However, when I tried to connect a 12VDC,3A power supply to the motor shield, I accidentally caused damage to my arduino board. So I bought a new one and did some research on power supplies for both the arduino and the motor shield and came to the conclusion that the arduino and motor shield must rather be powered up with their own power supplies. So hooked up my arduino to a 5VDC,2000mA unregulated power supply and the motor shield to a 12VDC,1000mA regulated supply and it seemed to work quite well although the motor shield overheated quite a bit. At htis point in time I didn't connect the thumb joystick because when I first connected the 12VDC powers upply to the motor shield in the beginning, the problem occured when I gave power to the joystick when my computer shut down and the arduino board got damaged. The joystick was connected to the pins on top of the motor shield when this happened. So I suspect that the thumb joystick couldn't handle the voltage and current and therefore shorted out something on the arduino.


I also purchased a proto screw shield which is now connected between the arduino and my motor shield so I can fasten the wires properly for a better arcade joystick I purchased. The arduino has its own power supply (5VDC,2000mA), the proto screw shield draws its power from the arduino's power supply and the motor shield has its own power supply (12VDC,1000mA). I also cut the extension pin for the Vin on the motor shield underneath the board so it doesn't draw power from the arduino. I hope this will overcome any shortage problems to the arduino and proto screw shields.


My question though is simple... Will my arcade joystick work if I connect it to the proto screw shield on the specified pins while both the arduino and the motor shield is powered with their repsective power supplies? I'm a little scared to just hook it up just to short out something...


I'm sorry to hear that happen to you, the reason that happen was because the arduino cant handle any current more then 40mA if i am not mistaken, however let me assure you that in any case, the pot can handle much more abuse then the arduino, a pot is just a variable resistor.

for you to connect the pot is 5V from the arduino connect to the end while the other end is connected to the gnd of any board,only the middle pin need to be connected at port A2. remember don't just take the power from the motor shield due to the arduino max voltage is 5vdc


Well, for the moment the Arduino board seems to be working quite well with the 5VDC,2000mA power supply. My biggest concern is the joystick. With the Vin extension pin cut underneath my motor shield board, there shouldn't be a way for the joystick to be affected by the motor shield's power supply, right? Or am I wrong to assume this?


And also, why do you think the motor shield is overheating with the 12VDC, 1000mA power supply? The board can actually handle up to 2amps per channel or 4amps in total if you drive a stepper motor and the operating voltage is 12V. Can I perhaps incorporate a PC fan into the box that I'll be using to enclose the boards so it can stay relatively cool? Will this help?


This lovely little shield is the best way to add a small, colorful and bright display to any project. We took our popular 1.8" TFT breakout board and remixed it into an Arduino shield complete with microSD card slot and a 5-way joystick navigation switch and three selection buttons! Since the display uses only 4 pins to communicate and has its own pixel-addressable frame buffer, it can be used easily to add a display & interface without exhausting the memory or pins.


New! We've updated this shield to be 'Arduino R3' format compatible so you can now use it with any and all Arduinos or Metros - including the Metro M0 or M4, Arduino Mega, Zero, etc. We also use Adafruit seesaw for the TFT backlight, TFT reset, and button inputs - you can query the buttons and joystick over I2C now, so only 2 pins are needed to communicate with all 8 switches.



The 1.8" display has 128x160 color pixels. Unlike the low cost "Nokia 6110" and similar LCD displays, which are CSTN type and thus have poor color and slow refresh, this display is a true TFT! The TFT driver (ST7735R) can display full 18-bit color (262,144 shades!).



The shield has the TFT display soldered on (it uses a delicate flex-circuit connector) as well as a ultra-low-dropout 3.3V regulator and a 3/5V level shifter so its safe to use with 3V or 5V Arduino compatibles. We also had some space left over so we placed a microSD card holder (so you can easily load full color bitmaps from a FAT16/FAT32 formatted microSD card), a 5-way navigation switch (left, right, up, down, select) and three tactile buttons marked A BC. The microSD card is not included, but you can pick one up here.



If you just want to display text, shapes, lines, pixels, etc the shield uses the SPI pins (SCK/MOSI/MISO), I2C pins (SDA & SCL) and digital #8. For the microSD card, you'll also give up Digital #4. This shield works with any Arduino UNO and compatibles, Mega, Zero, etc. If it's shield compatible, you're good to go.



Comes as a fully assembled and tested shield with the display, microsd card holder and nav switch as well as a stick of 0.1" header. To finish up and use, you will need to solder on the header onto the shield PCB, a quick 10 minute task.



Of course, we wouldn't just leave you with a datasheet and a "good luck!" - we've written a full open source graphics library that can draw pixels, lines, rectangles, circles, text and bitmaps as well as example code and a wiring tutorial. The code is written for Arduino but can be easily ported to your favorite microcontroller!

3a8082e126
Reply all
Reply to author
Forward
0 new messages