Hi, all! I'm very new to programming and using Arduinos and all this, and as such I really have no idea what I'm doing. I've had a 3d printer for a few years now and have a fairly good understanding of how that all works and how to modify that firmware and everything so I'm not entirely lost, but I am here.
I'm working on a university project and we're trying to use a QR code scanner to automate sorting sockets. We have a two-axis machine set up with an electromagnet to pick up and drop the sockets in an organizing tray. We have an Arduino MEGA with a RAMPS 1.4 board running marlin and I've been using Pronterface to send commands to it and everything is working as desired on that front. Where we're running into problems is with the code for the QR scanner. It is on a separate Arduino Uno and we want to be able to scan a QR code, have the Arduino interpret that, then have the Arduino send predetermined G-code to the RAMPS board. Does anyone have any ideas for how to code that to get the Uno to interpret the QR code and translate that into G-code that can be sent to the RAMPS board? Also, will it be able to send through a cable directly connecting the boards or do I need to come up with a different connection method for actually sending the instructions?
Any and all help would be very much appreciated, thank you!!
Okay, so do you have any ideas for how to do that? As I said in my post, I am very new to this whole Arduino, and coding in general, thing so I really am at a loss right now.
At this point, there is no coding necessary. What you need to do is document how the two devices might be able to communicate. If they can, only then can you consider coding.
If you are able to really modify a firmware you have a lot of coding experience that goes far behind any beginner. So where is the problem?
If modifying the firmware means:
look up a source-code according to a manual find some constant-names and change some numbers written behind the constants name. This is not really modifying a firmware
This is just making some small adaptions guided by the manual but not modifying.
For suggestions that shall go beyond what has been posted as general advice so far
you have to provide very detailed information about everything works.
unprecise information
what is a RAMPS 1.4 board???? Just some kind of hardware?
Some kind of hardware combined with a firmware running on the arduino-MEGA?
what do you mean by "it"???
The arduino Mega??? The ramps 1.4-board?
what is "Pronterface" ???
How is "Pronterface" connected to the Arduino-Mega???
What kind of interface does your QR-code-scanner have??
What is the content of your QR-codes?? (usually QR-codes have an URL inside)
There are millions ways of doing this. Again refers to the question above: what is inside your QR-code????
Man you are working on an informatic project. And what is needed most in an informatic project is information !
You can't expect any user here to think for hours about a concept how all this can be done.
Even lesser without knowing datasheets of all components that you are using.
You can make a short try:
Ask Siri or Alexa the text above as a test
if Siri or Alexa is able to offer an adequate answer.
My guessing is: Siri will say I'm sorry can't answer this should I print some helpful links
and alexa (belonging to amazon will start offering products that might be relevant)
And even this answer which will be given in seconds requires hundreds of manyears of development to give them.
Here is a link to the RAMPS 1.4 and Arduino Mega kit that we are using. It's basically a shield on top of the Arduino Mega that you plug the stepper motors, limit switches, and all that into. I've flashed Marlin firmware to it to have a means of getting our machine actually moving.
Technically both I think? as the RAMPS board is a shield on top of the Mega.
Pronterface is a piece of software that, when connected to the actual physical USB port on the Arduino Mega and my laptop, I can send G-code commands to our machine.
This is the QR code scanner we are using. Since G-code is just plain text, I'm thinking we can just generate the QR codes with the correct G-code in them, correct? In theory?
I guess to refine my question more, can the separate Arduino Uno with the QR scanner send that information to the Mega with the RAMPS board and Marlin on it? If so, how? Or should the QR scanner interface directly with the Mega and RAMPS board somehow? If so, how? Or should I just give up and quit trying because I don't know what I'm doing or how to ask my questions in the right way?
Your Arduino Mega shall drive multiple stepper-motors at the same time in a coordinated way. This requires a very tight timing. Very tight ! This means the arduino mega should concentrate on controlling the stepper-driving
If QR-code scanning and driving stepper-motors is always and strictly not overlapping in time you can connect the QR-scanner to the arduino mega. An Arduino Mega has three hardware serial interfaces which can receive serial data at higher baudrates 115200 baud
Your QR-code-scanner has a RS232-interface which can be connected to the arduino uno or the arduino mega as explained above
In case you want to receive QR-code data in parallel to stepper-driving it will be better to use a second microcontroller.
Though an arduino Uno is not the best choice for this because an uno has only one hardware serial interface.
a second one must be created by software which only works reliably on lower baudrates (best 9600 baud, or 19200 baud)
The one hardware serial should be reserved for serial debug-output.
A better choice would be a seeeduino XIAO which has two hardware serial interfaces, lotsä of RAM and flash and a higher clock than an uno
No not at all. Keep going. It is just that a lot of details must be defined to make it work.
This process of asking back will go on. Ask the way you want to ask.
If the question is somehow unprecise this just requires asking back for certain details
So next thing to answer is
receiving QR-code data in parallel to stepper-driving or not.
And describe how you make the marlinsoftware make the steppers move.
I guess I'm not entirely sure how to answer that or what direction to take to be honest. Our plan is to have the QR codes themselves on the sockets, each one will drop down onto a platform where it will be scanned by the QR scanner, that will then send the G-code embedded in the QR code (very simple G28 to home, M106 to turn on the electromagnet that is wired into the fan connections to pick up the socket, two, at most three moves from the steppers, and an M107 to turn the electromagnet off and drop the socket). This will be sent to the Mega with the RAMPS board and be handled by the Marlin firmware that's on there.
I guess, and I'm just thinking this through as I'm typing this, it's not necessary, as far as I know, for the G-code that's on the QR-code as plain text to be processed in parallel to stepper-driving. With my own 3D printer that is separate from this project but running the same Marlin firmware, I can send G-code commands myself one after the other before the last one has been fully completed and the printer will just execute the next command in that "backlog" when it completes the command it is working on at the time. I hope that all makes sense and I guess what I'm working out and thinking is that the QR-code data does not need to be received and interpreted in parallel with stepper-driving so I can, and probably should, have the QR scanner connected to a separate microcontroller that will send that bulk info from the QR code to the Mega with the Marlin firmware.
Marlin is just the firmware that I've loaded onto the Mega and RAMPS combo that interprets and executes the G-code. Pronterface is just the piece of software I use that establishes the connection between that microcontroller and my laptop and allows me to write and send commands myself like a terminal. I'm basically manually controlling it at the moment.
My original comments seem to be ignored, so let me restate them. At this point please get rid of your fixation on QR codes and concentrate on the Second Arduino being able to send ANY G-code to the processed by your system controller. Until that works, QR code is just a distraction from the real problem.
When the above works, then you can add the QR code process and you will be assured the G-code being created will be processed by your system.
Yea and my original comments to you seem to have been ignored as well. I tried to ask how I do that; how do I get the second Arduino to communicate and send information to the Mega and RAMPS combo running Marlin.
By using a secondary input port on your system. If it does not have one, then you have the option of adding it to the code or ? What does the documentation say?
right now you have a USB-cable between your computer and your Arduino Mega running the marlin-firmware.
If I understand right your computer sends G-code as ASCII-Text from your computer to the arduino-mega.
You are sending these G-codes with a software called pronterface from computer to the arduino-mega.
The marlin-firmware running on the arduino-mega receives the g-codes and makes your mechanic drive.
One important thing to know is:
will your QR-code-scanner be connected to the arduino-Mega instead of your computer using Serial
or
will your QR-code-scanner be connected in parallel to your computer?
Beeing connected in parallel to your computer means you have to modify the marlin-firmware.
Sorry for the late reply, we've been working on mostly hardware problems for this project lately so I've been focused on that.
The QR scanner will be connected to the Arduino Mega instead of my computer. Right now, I'm just using my computer to troubleshoot everything and interact with the machine in an easily accessible way. The idea for this project is to have a fully standalone system that just plugs into a wall outlet and works on its own without any human interaction.
I've made a few QR codes that have the G-code on them as plain text and sending that to our machine through my computer works so that in and of itself works. And I've hooked up the QR scanner to a separate Arduino Uno and everything there works as it should. Now I just need to get the two separate systems to interact with each other without the computer acting as the go between.
I've got a few things I'm going to try;
I'm sure this won't work but I have the cables anyway so why not try the easiest thing first and connect the USB on the QR code to the USB connection on the Arduino Mega. There's no way it'll be that easy but it's worth a shot.
The other thing I'm going to try is going to borrow from this article and use the I2C communication on the Arduino Uno and the RAMPS board. I have higher hopes for this, but am not entirely sure how I would need to modify the code from that article to work in this application.
Are you sure that Marlin is the right software to use? AFAIK it's highly optimised for 3D printers, it might be better to use GRBL which will run on a Uno and probably on your Mega, which can run 3-axis machines. It needs to be sent Gcode commands just like Marlin, but there are customisations e.g. for XY plotters that have been discussed here. Commands come in as text on a serial port and can be queued. The main problem you may have is that you can't get enough text in a QR code for the amount of code needed, but you could easily just use the code as a pointer to a database record that has as much code as you like. GRBL takes a lot of the available processor resource, I expect Marlin does too, so best to have a second processor streaming the gcode to it. That could be something like a Pi that has an OS and can handle databases etc.