Skip to content

DrBit/Seed-Counter

Repository files navigation

/********************************************
**  Name: Seed Counter
**  Created: 27/06/2011
*********************************************
**  REVISIONS from:
**
**  V5.3.1 - 19/02/2013
**  * Implemented counter autofix in network UI
**
**  V5.3 - 25/01/2013
**  * Changed blister error handling
**
**  V5.2 - 24/01/2013
**  * Fixed bug in autoreset function that would do autoresets to every blister
**  * Added min time polling server. Still not trough the server config
**  * Added Server polling timing
**
**  V5.1 - 23/01/2013
**  * Fixed bug that would prevent machin from restarting when an error "released blister error" ocurred
**  * Implemented function autoreset inside configuration variables.
**
**  V5.0 - 16/01/2013
**  * First usable version
**  * Added Auto reset function
**
**  V4.0.21 - 10/01/2013
**  * Fix delay when label not printed. Atleast wait for 2 seconds after receiving the label sensor signal
**  * Fix bug in finishing batch button
**  * Fix eject blister to avoid problems with the printer
**
**  V4.0.20 - 28/12/2012
**  * Trying new metoth for handling errors (in reset motors module)
**  * Added new flags to avoid endless loops when reseting machine.
**
**  V4.0.19 - 26/17/2012
**  * Added received actions (A) for enable/disable pump
**  * Adapted function reset all motors to react on server responses
**
**  V4.0.18 - 17/17/2012
**  * Added function skip_function to prevent functions to be executed in case we need to go to the start point
**  * Fixed all errros to update status to send_error_to_server(missing_blister_info); when error is solved
**  * Fixed bug when printing on screen error of label timeout
**  * Merged function stop + pause into one.
**
**  V4.0.17 - 12/12/2012
**  * Added file Test_mode.ino
**  * Improbed counter init, now it goes back so we can turn off the pump and not lose a seed
**  * Improved end of batch functions
**  * Added some security when stopping and switching down
**  * Added continious check of lables when getting a time-out
**
**  V4.0.16 - 11/12/2012
**  * Cleaning of code
**  * Improved function wait_for_blister_info
**  * Cleaned Power handling functions
**  * File name changed Power_handling
**  * Added setting up function inside Stop state
**  * Fixed some bug + IDLE timer
**  * Fixed sensors atribution
**
**  V4.0.15 - 10/12/2012
**  * Added some debug tags
**  * Reformed function check_stop
**  * Added new file power_saving.ino
**  * Added G command
**  * Changed blister mode behaviour
**  * Changed some logging cosmetics
**
**  V4.0.14 - 07/12/2012
**  * Changed Idle timer into more realistic mills() counter.
**
**  V4.0.13 - 06/12/2012
**  * Finished function bypass server
**  * Added Idle timer in the check pause function
**  * Improved timeout reading when in DEBUG mode
**  * Fixed bug in the counter
**  * Fixed bug in Autofix Counter
**
**  V4.0.12 - 10/09/2012
**  * Added function to bypass server (needs further implementation)
**  * Changed blister functions to work with servo motors and also stepper (we choose wich ones to use)
**
**  V4.0.11 - 10/07/2012
**  * Fixed bug switch off functions that would prevent a wake up from switch off state
**  * Improved switch off/on and reset functions
**
**  V4.0.10 - 09/07/2012
**  * Implemented pause, stop, and reset functions
**  * Fixed Database bug, rewriting itself
**  * Added vibration into counter behaviour
**
**  V4.0.9 - 06/07/2012
**  * Fixed bug in the counter process when sending data to the server we would lose events on the sensor
**  * Fixed Y axis movement directions
**  * Added configuration of the sensor
**  * Added function to operate solenoid 1
**
**  V4.0.8 - 05/07/2012
**  * Fixed bug in the process of quering the server
**  * Implemented new default sensor state
**  * Library changed to version 15
**
**  V4.0.7 - 23/06/2012
**  * Fixed bug in the DB memory assignment
**  * Speed up comunications wetween the server significantly
**
**  V4.0.6 - 22/06/2012
**  * Fixed bug with comunication
**  * Adding new command C for (config) (in process of implementation)
**  * Added debug net comunications
**  * Increased number of Database lines
**  * Added recordings to the EEPROM of basic config og local IP, server IP, server PORT and MAchine ID
**
**  V4.0.5 - 19/06/2012
**  * Preparing for deployment, fixed bugs. Still something to fix before functional
**
**  V4.0.4 - 16/06/2012
**  * Improved start-up routine. Mandatory a connection to the server before any setup process...
**
**  V4.0.3 - 16/06/2012
**  * Added Debug motors function. It will ignore any fail in sensors and run as if everey sensor works normal.
**  * Cleaned setup process
**
**  V4.0.2 - 15/06/2012
**  * Added function "get_positions_from_server" 
**  * Added function "receive_server_data"
**  * Improved functions "check_server", "connect_to_server", "setup_network"
**  * Added function "receive_server_data"
**  * Added function "receive_server_data"
**  * Added command "get_default_off_time"
**  * Updated documentation.txt
**
**  V4.0.1 - 13/06/2012
**  * Changed files to INO
**  * Added function send status
**  * Mapped new arduino pins
**  * Creating new server report functions
**
**  V4.0 - 12/06/2012
**  * First merged version into master branch
**  * Added Connections to server fail methods
**
**  V3.13 - 04/25/2012
**  * Testing Bug of Yaxis displacement
**
**  V3.12 - 29/02/2012
**  * Changed to second row when using the 5 seeds mode
**
**  V3.11.2 - 18/04/2012
**  *Removed Label Printer functions
**  *Added Ethernet module functions
**  *Added documentation.txt file for writing notes
**  *Changed name of list actions to "list_commands_ethernet.h"
**  *Added new version of library Stepper_AC V1.4 (UNO compatible)
**
**  V3.11.1 - 07/03/2012
**  * Added new errors and actions
**  * Updated commands list
**
**  V3.11 - 22/02/2012
**  * Added testing pump
**  * Fixed bug in print_and_realease_label
**  * Added batch numbers 4 cyfers
**
**  V3.10 - 16/02/2012
**  * Added function finish batch
**  * Added more pump enable/diable actions in the code
**  * Added boring messages
**  * Major improve in IDLE timers
**  * Cleaned loop from complex bloks
**
**  V3.9 - 14/02/2012
**  * Added function in too many wheel counts
**  * Added various logging and user visivility
**
**  V3.8 - 10/02/2012
**  * Added 5/10 mode blisters selector
**  * Fixed positions in 5 seeds blister mode
**
**  V3.7 - 07/02/2010
**	* Added pin to Pump functions (Relay to be implemented)
**  * Relocated network configuration file
**  * Incremented safe distance in counter sensor (avoids triggering errors)
**
**  V3.6 - 06/02/2010
**  * Added emergency button function
**	* Added Pump functions (Relay to be implemented)
**
**  V3.5.1 - 26/01/2010
**  * Splited list of actions and errors into a new file. Added Status
**
**  V3.5 - 31/01/2010
**  * Added function to check sensors at printer label position
**  * Added autostart after blisters are refilled (during refilling)
**  * Added error checking in the counter. If seed is detected where it shouldnt. (avoids constant seed picking)
**  * Added functionality in blisters errors (in sensor position)
**  * Added autofix when error in coutner wheel losing steps.
**  * Changed a bit all loop distribution
**
**  V3.4.2 - 18/01/2012
**  * Added actions and errors to the list 
**
**  V3.4.1 - 06/01/2012
**  * Cleaning and preparing code for new UI interface (not operble yet)
**
**  V3.4 - 25/01/2010
**  * Added function to check sensors out of listers and sensor blister not releasd correctly
**  * Changed a bit all loop distribution
**  * Changed few functions to adapt to new UI
**
**  V3.3.3 - 18/01/2010
**  * Setup process cleaned, create several sub-functions
**	* New sensor pins definend, also Emergency button.
**  * Added pre-functions of new sensors
**
**  V3.3.2 - 17/01/2010
**  * Configuration migrated to the server 10.250.1.3
**
**  V3.3.1 - 11/01/2012
**  * Adjusted positions
**
**  V3.3 - 06/01/2012
**  * Added new brush position
**  * Added new errors and commands for serial com.
**
**  V3.2 - 06/12/2011
**  * Set default direction for blister motors
**  * Added extra steps on blisters motors in case we lose some at a certain moment.
**  * Fixed statistics for longer than one hour
**  * Fixed bug in menu statistics
**  * Increased speed of Y axis, decreased X axis
**
**  V3.1 - 30/11/2011
**  * Adjustments to all parameters
**	* Fix bug in menus
**
**  V3.0 - 18/11/2011
**  * NEW PROTOTYPE V3
**  * Added fucntion to change the default direction of the motors without changin anything on the code
**  * All positions updated
**  * Created fucntion to update EEPROM positions at once (Manual)
**  * Improved functionupdate position of the menu
**
**  V2.2 - 18/10/2011
**  * Network comunication WORKING
**  * Changed some parameters to improve speed
**  * Fixed minor errors in statistics calculations (added aproximation if hour is < 1)
**  * Fixed bug in counter statistics & improved speed
**  * Improved starting time of the check process
**  * Fixed bug in counter where would use total turns for error checking
**
**  V2.1.19 - 18/10/2011
**	* Added automatic reset of network module (Uses pin 39 in arduino mega)
**  * Fixed bug init and changed init procedure 
**  * Added function receive and print configuration from Ethernet module
**
**  V2.1.18 - 17/10/2011
**	* In field testing of all new features
**  * Fixed statitsitcs bug
**  * Fixed settings update of network module (still minor bug to check (ip))
**
**  V2.1.17 - 08/10/2011
**  * Added  statistics + pause menu
**  * Batch number selection ready to be implemented in network side
**  * Code rediability 
**
**  V2.1.16 - 05/10/2011
**  * Added functions to record positions in internal EEPROM
**  * Added function to adjust memory positions
**  * Adde network configure process (Still to test)
**
**  V2.1.15 - 03/10/2011
**  * Fine tune parameters. 1rst running production. WORKS!
**
**  V2.1.14 - 2/10/2011
**  * Added basic comunication handling with network module
**	* Fine tuned comunication protcol
**	* Splited functiond command in Command & Error
**
**  V2.1.13 - 1/10/2011
**  * Starting process of implementing communication with network module 
**
**  V2.1.13 - 28/09/2011
**  * Fixed bug in the counter sensor and position of the wheel when initializing the counter
**	* Increased range of detection of seeds in the counter
**	* Addes some motor parameters definitions in setup (Acceleration and speed defaults)
**  * Added label printer init function
**
**  V2.1.12 - 20/09/2011 
**	* Merged branch acceleration
**  * Fine tune positions in the prototype
**  * Serial speed changed to maxim
**
**  V2.1.11 - 20/09/2011  (new branch)
**  * Changed acceleration metoth 
**  * Updated library to V1.2 (acceleration in motors)
**
**  V2.1.10 - 17/09/2011
**	* Updated hardcode of positions into solid state memory
**
**  V2.1.9 - 15/09/2011
**  * Updated positions for blisters
**  * Releas blisters function improved
**  * Improved pause button
**
**  V2.1.8 - 14/09/2011
**  * Changed behavior of the INIT counter procedure to match new counting system (with vibration from the same wheel)
**  * Optimized parameters in counter and blister dispenser
**  * Updated Library to V1.1 (fixed bug) 
**
**  V2.1.7 - 07/09/2011
**  * Added Vibrator in TEST menu (later removed)
**
**  V2.1.6 - 31/08/2011
**  * Sensor PIN B changed from 13 to 4 (due to problems with led conected in pin 13 via hardware)
**  * Removed "go to position X Y" function and included into library, now available for all motors
**  * Updatedlibrary to V1.0
**
**  V2.1.5 - 25/08/2011
**  * Fixed bug in motors handling that would prevent moving small number of steps in motor modes 1,2 and 4 
**    due to lack of resolution.
**  * Implemented function "go to position X Y" (for now only for X motor). The function will determine how to move
**  * the motor in order to go to the specific position with the better possible way (added in test menu).
**  * Added Version tracking to warn user when working whith an outdatet version of the library (from version 0.6.3)
**
**  V2.1.4 - 23/08/2011
**  * Adapted function pick a seed for the new hardware
**  * Implemented DEBUG function
**  * Created new motors handling function. For now with fixed acceleration and only for X motor (Test option in Menu)
**
**  V2.1.3 - 18/08/2011
**  * Added testing menu function
**  * Changed init order of motors to first init the blisters
**  * Added counter manual mode + print position
**  * Added file "Label_printer.pde"
**
**  V2.1.2 - 17/08/2011
**  * Added "press_button_to_continue(int button_number)" and "return_pressed_button ()" in extra fucntions
**  * Fixed bugs in XY axis init process.
**  * Added main menu with function show sensor status
**  * Implemented counter init procedure
**  * Added a full error control sistem in init procedures
**  * Added serial compatibility when pressing buttons 1,2,3
**  * Changed names of the main files 
**    "Stepper_ac06.h" -> "Stepper_ac.h" /  "Seed_counterV2.1.pde" -> "Seed_counter.pde"
**
**  V2.1.1 - 11/08/2011
**  * Added control of the axis limits in manual mode to avoid going to far and damaging the sensors 
**    or going off limits.
**  * Added Manual mode for the blisters dispenser
**  * Changed to the new library version 0.6 "Stepper_ac06.h"
**
**  V2.1.0 - 10/08/2011
**  * Merging code from previous motor testings
**  * Created new set of functions for controlling blister's motors "blisters.pde"
**  * Implemented error checking system in XY motors init algorithm. Depured code.
**  * Added velocity control of the motors. MS1,MS2 conencted from Arduino to the "easy driver" 
**    (functions included in library "Stepper_ac05.h")
**  *
**  V2.0 - 27/06/2011
**  * Changed hardware, new motors, new functionality, complete code reset
**  * Testing New motors
**
**  V1.4 - 31/05/2011
**  * Implement 2 holes pick-up seed
**  * Improved INIT sequence of the counter
**  * Check free memory during program
**  * removed first time drop function (instead included in motor_INIT function)
**
**  V1.3 - 13/05/2011
**  * Included version 0.5 of library
**  * Improved steps counting (in library "Stepper_ac05.h")
**  * Code readability improved
**  * Implemented PROGMEM to store data of the matrix into flash memroy (on hold waiting for 
**    new HW prototype version)
**  * Added serial debugging
**
*********************************************

TODO

Change the handling of movements in manual mode. (Diff speeds depending on how long you press the button)

New sensors 
	Sense if a blister correctly placed in the X axis conveier (Also works for empty blisters)
	Sensor need to be positioned in a way that will also sense when the blister is offset
	
	Sensor for printer, lable printed and placed correctly

Relay board for on off

Handle motors sleep / reset and enable
	Create functions sleep
	Emergency stop


*/

About

Seed Counter prototype

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages