====== Controller / Firmware ====== M-Code steered Arduino Mega Shield to control servos in 3d printed feeder. Additionally firmware has capabilities to read some analog channels (e.g. for vacuum sensors) and switch some mosfets to power some peripherials. Used in combination with [[maschine:pickandplace:feeder:0816feeder:mechanics|3d printed 0816-automatic feeder]]. ===== Features ===== * two alternative shields, one firmware ready for both * firmware for Arduino Mega * handles up to 24 feeder (native shield) resp. 48 feeder (sensor shield) * advance tape 2 mm and multiples of that * interfaces via G-Codes received per serial communication * seamless integration into OpenPnP via G-Code-Driver and it's actuator system * controller checks status of feeder and passes an occuring error to host (e.g. feeder not loaded, cover tape tension insufficient) (native shield only) * Manual feed: Press on cover tape tensioner for a short time to feed. Useful to setup feeder. (native shield only) * Additional Non-Feeder related features (native shield only): * read up to 8 analog channels and report it's value to OpenPnP * scaling and offsetting raw analog values to real units * up to 4 power output * 2 special analog channels prepared to read NXP vacuum sensors ====== Controller-Shield for Arduino Mega ====== ^ ^ [[maschine:pickandplace:feeder:0816feeder:nativeshield|Native Shield]] ^ [[http://arduino-info.wikispaces.com/SensorShield#SSM|Arduino Mega Sensor Shield v2.0]] ^ | | {{maschine:pickandplace:feeder:0816-controller-pcb_photo_cutted.png?200|0816 automatic smt feeder arduino native shield}} | {{:maschine:pickandplace:feeder:sensor-shield-v2.jpg?200}} | | supported by firmware out of the box | ✓ | ✓ | | Number of feeder | 24 | 48 | | Manual feed by tapping on tape tensioner | ✓ | - | | Check feedback line for sufficient tape tension | ✓ | - | | 2 optional vacuum sensors | ✓ | - | | 4 optional power output | ✓ | - | | power from arduino or external | ✓ | ✓ | | enable/disable power for all feeder via g-code | ✓ | - | | where to get? | [[maschine:pickandplace:feeder:0816feeder:nativeshield#sources_for_0816_controller_shield_pcb|OSHpark and co.]] | [[https://www.amazon.com/Sensor-Shield-Expansion-Arduino-ATMEGA/dp/B07518PHWX|amazon.com]] and others | ===== Setup the Controller ===== ==== 1. Power supply for Feeder ==== Choose how to supply power to the feeder: ^ type ^ source ^ how to activate that type? ^ useful for ^ precaution ^ | **internally powered** | arduino 5v line | set a jumper on the pinheader INT_PWR (native shield) resp. PWR_SEL (sensor shield) | prototyping | don't connect external power | | **externally powered** | external 5V power supply | remove jumper from INT_PWR (native shield) resp. PWR_SEL (sensor shield) and \\ connect supply to FEEDER_PWR resp. the only screw block (sensor shield) | production | | ==== 2. Download, Compile and Upload Firmware ==== Get the currentmost firmware at [[https://github.com/mgrl/0816-feeder-firmware]]. === Configure and Build === Use Arduino IDE to build and upload to microcontroller. Precompiled files are not available. Adapt firmware to your needs by modifying config.h. Most of the settings should not need to be touched as they are preconfigured properly already. Anyway there is a config.h to enable/disable debugging, change serial baud rate and choose the controller shield. #define DEBUG // disabled (commented) by default. uncomment to get some debug data printed via serial #define CONTROLLER_SHIELD NATIVE_SHIELD //compile for native shield (NATIVE_SHIELD) or sensor shield (SENSOR_SHIELD) #define SERIAL_BAUD 115200 //set speed of serial communication == Dependencies == Install the following libraries via Arduino Library Manager: * EEpromEx * Servo === Test Firmware === Open serial monitor within Arduino IDE and see whether the controller works. There should be messages on startup that inform about the settings hold in eeprom. Test some commands in the serial monitor to see whether communication works as expected before setting up in OpenPnP. ==== 3. Wire a Feeder ==== In combination with the native shield all 4 pin connect to the controller. If you chose to use the sensor shield, the feedback line is left unconnected. {{:maschine:pickandplace:feeder:connect_feeder.png|}} The native shield has the maptable printed on. For the sensor shield the maptable is as the image depicts: {{:maschine:pickandplace:feeder:0816feeder:mega-sensor-shield_maptable.png?400|}} ==== 4. Test Feed ==== The following commands should work if everything is setup properly. A [[maschine:pickandplace:feeder:0816feeder:mcodes|full list of available commands]] is listed below. M610 S1 ; enable feeder M600 N0 F4 ; feeder N0 advance tape 4mm M601 N0 ; retract advancing lever (next time feed is faster, this command is a post-pick command) M600 N0 F2 ; feeder N0 advance tape 2mm M600 N0 F2 ; feeder N0 advance tape 2mm M600 N0 F12 ; feeder N0 advance tape 12mm M610 S0 ; disable feeder If the feeder doesn't move and an error pops up on the console, check the feeder status with M602 N0 ; print N0 feeder status If it reports an error, the feedback-line might not setup properly. Fix it by checking the cabling. Temporarily the error check can be overridden by adding X1 to the feed command: M600 N0 F4 X1 ; feeder N0 advance tape 4mm ignoring errors ==== 5. Finetune Configration ==== The firmware comes preset for the feeders mechanics. But it may be the case, that the servo angle is a little different from manufacturer and how the servo controller handles the incoming PWM signal. For this reason every feeder has a configuration set. Adapt it so that commanding the servo to 0°/90° indeed makes the servo go to 0°/90°. The current configuration setting per feeder is printed with M620 N0 ; display settings for feeder N0 The meaning of each argument is to be seen in the [[maschine:pickandplace:feeder:0816feeder:mcodes#m620set_feeder_config|detailed list]]. * Check whether the PWM signal timing arguments suit your servo * Check whether the servo settles within settle time, otherwise raise it * Check for correct angles M603 N0 A55; set servo on feeder N0 to angle 55° Once found a proper configuration, set the values globally in config.h or issue an M620 command with correct values for every feeder. ==== Finished: Go on with Integration into OpenPnP ==== -> see [[#setup_controller_in_openpnp|next chapter]] ===== Setup Controller in OpenPnP ===== The feeder and its controller are designed to suit well to OpenPnP, so nothing special is required to get them to work with OpenPnP. To set up one or more feeder follow the next three steps. ==== 1. Add G-Code-Driver for 0816 Feed Controller ==== * add GCode-Driver * set port and baud rate (default 115200) * set timeout to 10000 ms * add command COMMAND_CONFIRM_REGEX and COMMAND_ERROR_REGEX (see below) {{:maschine:pickandplace:setup_0816feeder_actuators_gcode_confirm.png?400|}} {{:maschine:pickandplace:setup_0816feeder_actuators_gcode_error.png?400|}} ==== 2. Add Actuators ==== In general, there are as many actuators needed as feed lengths are desired. Example: The feeder shall be able to feed 4mm (0805 resistors), 8mm (some ICs) and 12mm there will be 3 actuators to be created, each for one feed length. Every feed-length has to be setup only once, not per feeder. See machine.xml regarding the actuator elements: ... ... ... ... ... {{:maschine:pickandplace:setup_0816feeder_actuators.png?400|}} For each actuator the G-Code passed to the 0816-controller when a feed command is issued has to be added (example below). The feed command is M600 per default. The Parameter N is the index of the feeder (zero based) and F the feed length in millimeter. Please note that the actuator's name and the value for the parameter F correspond each other. So actAutoFeeder**4mm** will have the command M600 N{IntegerValue} F**4**. {{:maschine:pickandplace:setup_0816feeder_actuators_gcode_feed4mm.png?400|}} === Do a Test Feed === In the actuators tab click one of the actuators just setup. Put a "0" into "Set Double" to issue a feed command on the first feeder. Click "Set" fires the G-Code to be sent off to the controller and makes the feeder advance the desired length. {{:maschine:pickandplace:setup_0816feeder_actuators_test.png?400|}} ==== 3. Add ReferenceAutoFeeder ==== Add a ReferenceAutoFeeder in the feeder tab for every physically existing feeder lane. In the field "actuator-name" fill in one of the actuators created in step 2. Example: If the feeder shall advance 8mm, set the actuator-name to "AutoFeeder_8mmAdvance". In field "actuator-value" the ID of the feeder comes into. The index is 0 based, so 0 will be the first feeder, 23/47 the last. The PostPick actuator is optional but useful to speed up feeding. After a pick, the feeder retracts if needed and gets ready for next feed. .. .. {{:maschine:pickandplace:setup_0816feeder_feedertab1.png?400|}} {{:maschine:pickandplace:setup_0816feeder_feedertab2.png?400|}} ==== Finished: Go on with setting the feeders' locations, ... ==== see https://github.com/openpnp/openpnp/wiki/Setup-and-Calibration:-Feeders and https://github.com/openpnp/openpnp/wiki/ReferenceAutoFeeder {{:maschine:pickandplace:feeder:0816feeder:feeder_rotation_mount.png?500|}}