Go Down

Topic: encoder (Read 16 times) previous topic - next topic

mingki

Thank you.
I pasted the first tab(main file for encoder driven object sorter) in the new etherpad.

mingkimingki@gmail.com

mem

If the encoder can be easily connected it would be helpful to run that code and see if it works as expected before you make any other changes. Of course you will still have the issue with the counts not being exactly right after one or two revolutions but we should make sure that the dropping logic is working correctly


When that is working you can then modify the code in loop so it uses the photo-detector to determine the beginning of each cycle (instead of using the encoder count)

mingki

Yes, I can get the encoder attach to either on the conveyor or on a breadboard easily. I feel excited to see how it will work with encoder and beam sensor combination. I wil prepare the encoder on a breadboard.
I've been continue to test with both encoder sketch and beam sensor sketch(the latest).
I've been keep trying to test by changing the first solenoid pin(between digital pin 2 to digital pin 4).
Whenever I test, one of the pin between digital pin 2 ~ digital pin 4 always never activates just like the situation I informed you before.
At that time, the digital pin 4 is never activated which was assigned for the lightest weight objects.


mingkimingki@gmail.com

mingki

Hi, mem.
I am trying to get the user interface working.
Whenever I run the processing file, the error message(ArrayIndexOutOfBoundsException:3) is keep showing this message.
Code: [Select]
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version   = RXTX-2.1-7
[0] "COM3"

Exception in thread "Animation Thread" java.lang.ArrayIndexOutOfBoundsException: 3
     at SorterUI.setup(SorterUI.java:68)
     at processing.core.PApplet.handleDraw(PApplet.java:1402)
     at processing.core.PApplet.run(PApplet.java:1327)
     at java.lang.Thread.run(Thread.java:619)

Above message appears as println(" Connecting to -> " + Serial.list()[portIndex]); is highlighted in yellow color.
I saved the processing sketch to a new subdirectory in the processing sketch directory and changed the com port according to my arduino com port but it is not working although I never modified anything in the processing sketch.
Is it because I have modified the arduino sketch?
I pasted the processing sketch in the new etherpad.

mingkimingki@gmail.com

mem

The Processing code is trying to use the com port index 3 port and it looks like your machine only has one port and that is Com3.  Check that Your arduino is indeed connected to Com3 (look in the tools/serial port menu in the arduino IDE and see if Com3 is checked and that no other Com port is shown.
If so, change the Processing line:
 public static final short portIndex = 3;  // select the com port
to
 public static final short portIndex = 0;  // select the first com port

mingki

Thank you.
Yes, I checked the com port of arduino and it is com 3.
I modified as you advised me and now I can see this.
http://www.flickr.com/photos/34955071@N02/3994943188/sizes/o/
It shows no information as I interrup the beam sensor.

mingkimingki@gmail.com

mem

Perhaps no data is being sent, did you change the any code in the communcation tab - perhaps we remove the serial messages for the UI so it was easier to see other debug messages.

I have created another etherpad for the code in the communication tab: http://etherpad.com/mingki-communication

You can past the code there, but to save time, if you see a line like:
 #define NO_UI
you can try it with that commented out or removed.

mingki

Hi, mem. How are you?
I eliminated #define NO_UI or just NO_UI, and tried but the result is same. I used the communication sketch of arduino which is version 1.
Version 2 had the #ifndef NO_UI in the communication sketch.
I pasted the communication skech to the etherpad link you shown me in the previous post.

mingkimingki@gmail.com

mem

Can you post the serial output. Capture it from the sketch startup until a couple of objects would have been dropped

mingki

Hi, mem.
OK, I will do that. Unfortunately, I am still on my duty now,
so I will post it tomorrow evening.
Have a good day.

mingkimingki@gmail.com

mingki

This is from the serial monitor when I uploaded the version 1 communication sketch to arduino and tested. If this is not what you meant, please let me know.
Code: [Select]
{,25,16,25,24,23,22,21,20,16,15,14,13,12,8,7,6,5,4,
|@,16,0,1,10,20,30,40,50,60,70,80,90,100,110,120,130,140,
start
Cup entering activation area
adding pos 25,solenoid nbr: 1-at tail pos: 0
|~,25,16,25,77,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Cup exiting activation area
Cup entering activation area
adding pos 6,solenoid nbr: 14-at tail pos: 1
|~,25,16,25,38,6,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Cup exiting activation area
Cup entering activation area
adding pos 4,solenoid nbr: 16-at tail pos: 2
|~,25,16,25,25,4,6,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,384,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Cup exiting activation area
Cup entering activation area
adding pos 12,solenoid nbr: 11-at tail pos: 3
|~,25,16,25,25,12,4,6,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,98,384,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Cup exiting activation area
Cup entering activation area
adding pos 5,solenoid nbr: 15-at tail pos: 4
|~,25,16,25,255,5,12,4,6,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,137,98,384,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Cup exiting activation area
Cup entering activation area
adding pos 5,solenoid nbr: 15-at tail pos: 5
|~,25,16,25,255,5,5,12,4,6,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,130,137,98,384,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Activating  Solenoid 16
Cup exiting activation area
Cup entering activation area
adding pos 25,solenoid nbr: 1-at tail pos: 6
|~,25,16,25,77,25,5,5,12,0,6,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,130,137,98,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Activating  Solenoid 14
Cup exiting activation area
Cup entering activation area
adding pos 25,solenoid nbr: 1-at tail pos: 7
|~,25,16,25,154,25,25,5,5,12,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,130,137,98,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Cup exiting activation area
Cup entering activation area
adding pos 25,solenoid nbr: 1-at tail pos: 8
|~,25,16,25,255,25,25,25,5,5,12,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,130,137,98,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Activating  Solenoid 15
Cup exiting activation area
Cup entering activation area
adding pos 14,solenoid nbr: 9-at tail pos: 9
|~,25,16,25,154,14,25,25,25,5,0,12,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,71,0,0,0,130,0,98,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Activating  Solenoid 15
Cup exiting activation area
Cup entering activation area
adding pos 4,solenoid nbr: 16-at tail pos: 10
|~,25,16,25,255,4,14,25,25,25,0,0,12,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,268,71,0,0,0,0,0,98,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Cup exiting activation area
Cup entering activation area
adding pos 4,solenoid nbr: 16-at tail pos: 11
|~,25,16,25,255,4,4,14,25,25,25,0,0,12,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,0,246,268,71,0,0,0,0,0,98,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Cup exiting activation area
Cup entering activation area
adding pos 4,solenoid nbr: 16-at tail pos: 12
|~,25,16,25,255,4,4,4,14,25,25,25,0,0,12,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,227,246,268,71,0,0,0,0,0,98,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Cup exiting activation area
Cup entering activation area
adding pos 25,solenoid nbr: 1-at tail pos: 13
|~,25,16,25,255,25,4,4,4,14,25,25,25,0,0,12,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,227,246,268,71,0,0,0,0,0,98,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Activating  Solenoid 16
Cup exiting activation area
Cup entering activation area
adding pos 25,solenoid nbr: 1-at tail pos: 14
|~,25,16,25,255,25,25,4,4,0,14,25,25,25,0,0,12,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,227,246,0,71,0,0,0,0,0,98,0,0,0,0,0,0,0,0,0,0,0,0,0,
Activating  Solenoid 16
Activating  Solenoid 11
Cup exiting activation area
Cup entering activation area
adding pos 25,solenoid nbr: 1-at tail pos: 15
|~,25,16,25,255,25,25,25,4,0,0,14,25,25,25,0,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,227,0,0,71,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Activating  Solenoid 16
Cup exiting activation area
Cup entering activation area
adding pos 25,solenoid nbr: 1-at tail pos: 16
|~,25,16,25,255,25,25,25,25,0,0,0,14,25,25,25,0,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,71,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Cup exiting activation area
Cup entering activation area
adding pos 4,solenoid nbr: 16-at tail pos: 17
|~,25,16,25,154,4,25,25,25,25,0,0,0,14,25,25,25,0,0,0,0,0,25,0,0,0,0,0,0,0,303,0,0,0,0,0,0,0,71,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Cup exiting activation area
Cup entering activation area
adding pos 4,solenoid nbr: 16-at tail pos: 18
|~,25,16,25,255,4,4,25,25,25,25,0,0,0,14,25,25,25,0,0,0,0,0,25,0,0,0,0,0,0,270,303,0,0,0,0,0,0,0,71,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Cup exiting activation area
Cup entering activation area
adding pos 25,solenoid nbr: 1-at tail pos: 19
|~,25,16,25,255,25,4,4,25,25,25,25,0,0,0,14,25,25,25,0,0,0,0,0,25,0,0,0,0,0,0,270,303,0,0,0,0,0,0,0,71,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Cup exiting activation area
Cup entering activation area
adding pos 25,solenoid nbr: 1-at tail pos: 20
|~,25,16,25,255,25,25,4,4,25,25,25,25,0,0,0,14,25,25,25,0,0,0,0,0,25,0,0,0,0,0,0,270,303,0,0,0,0,0,0,0,71,0,0,0,0,0,0,0,0,0,0,0,0,0,
Activating  Solenoid 16
Cup exiting activation area
Cup entering activation area
adding pos 25,solenoid nbr: 1-at tail pos: 21
|~,25,16,25,255,25,25,25,4,0,25,25,25,25,0,0,0,14,25,25,25,0,0,0,0,0,25,0,0,0,0,0,0,270,0,0,0,0,0,0,0,0,71,0,0,0,0,0,0,0,0,0,0,0,0,
Activating  Solenoid 16
Cup exiting activation area
Cup entering activation area
adding pos 25,solenoid nbr: 1-at tail pos: 22
|~,25,16,25,255,25,25,25,25,0,0,25,25,25,25,0,0,0,14,25,25,25,0,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,71,0,0,0,0,0,0,0,0,0,0,0,
Activating  Solenoid 9
Cup exiting activation area
Cup entering activation area
adding pos 25,solenoid nbr: 1-at tail pos: 23
|~,25,16,25,255,25,25,25,25,25,0,0,25,25,25,25,0,0,0,0,25,25,25,0,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Cup exiting activation area
Cup entering activation area
adding pos 25,solenoid nbr: 1-at tail pos: 24
|~,25,16,25,255,25,25,25,25,25,25,0,0,25,25,25,25,0,0,0,0,25,25,25,0,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Cup exiting activation area
Cup entering activation area
adding pos 25,solenoid nbr: 1-at tail pos: 0
|~,25,16,25,255,25,25,25,25,25,25,25,0,0,25,25,25,25,0,0,0,0,25,25,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Cup exiting activation area
Cup entering activation area
adding pos 25,solenoid nbr: 1-at tail pos: 1
|~,25,16,25,255,25,25,25,25,25,25,25,25,0,0,25,25,25,25,0,0,0,0,25,25,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Cup exiting activation area
Cup entering activation area
adding pos 25,solenoid nbr: 1-at tail pos: 2
|~,25,16,25,154,25,25,25,25,25,25,25,25,25,0,0,25,25,25,25,0,0,0,0,25,25,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Cup exiting activation area
Cup entering activation area
adding pos 25,solenoid nbr: 1-at tail pos: 3
|~,25,16,25,255,25,25,25,25,25,25,25,25,25,25,0,0,25,25,25,25,0,0,0,0,25,25,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Cup exiting activation area
Cup entering activation area
adding pos 25,solenoid nbr: 1-at tail pos: 4
|~,25,16,25,255,25,25,25,25,25,25,25,25,25,25,25,0,0,25,25,25,25,0,0,0,0,25,25,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Cup exiting activation area
Cup entering activation area
adding pos 25,solenoid nbr: 1-at tail pos: 5
|~,25,16,25,255,25,25,25,25,25,25,25,25,25,25,25,25,0,0,25,25,25,25,0,0,0,0,25,25,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Cup exiting activation area
Cup entering activation area
adding pos 25,solenoid nbr: 1-at tail pos: 6
|~,25,16,25,255,25,25,25,25,25,25,25,25,25,25,25,25,25,0,0,25,25,25,25,0,0,0,0,25,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Cup exiting activation area
Cup entering activation area
adding pos 25,solenoid nbr: 1-at tail pos: 7
|~,25,16,25,255,25,25,25,25,25,25,25,25,25,25,25,25,25,25,0,0,25,25,25,25,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Cup exiting activation area
Cup entering activation area
adding pos 25,solenoid nbr: 1-at tail pos: 8
|~,25,16,25,255,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,0,0,25,25,25,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Cup exiting activation area
Cup entering activation area
adding pos 25,solenoid nbr: 1-at tail pos: 9
|~,25,16,25,255,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,0,0,25,25,25,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Cup exiting activation area
Cup entering activation area
adding pos 25,solenoid nbr: 1-at tail pos: 10
|~,25,16,25,154,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,0,0,25,25,25,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Cup exiting activation area

mingkimingki@gmail.com

mem

That Arduino output looks ok, perhaps your Processing sketch is not using the correct port.

Post the text from the Processing Serial monitor window so I can see what ports Processing recognizes and which one it is using.  It prints this information when the sketch starts

mingki

I just tested, and the error message says "ArrayIndexOutOfBoundsException: 5
and the serial monitor showed below result.
Code: [Select]
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version   = RXTX-2.1-7
[0] "COM5"

Exception in thread "Animation Thread" java.lang.ArrayIndexOutOfBoundsException: 5
     at SorterUI.setup(SorterUI.java:68)
     at processing.core.PApplet.handleDraw(PApplet.java:1402)
     at processing.core.PApplet.run(PApplet.java:1327)
     at java.lang.Thread.run(Thread.java:619)

The com port I use now is com5.

mingkimingki@gmail.com

mem

#493
Oct 10, 2009, 02:38 pm Last Edit: Oct 10, 2009, 02:39 pm by mem Reason: 1
The Com port is selected in Processing with the following line:
 public static final short portIndex = 1;  // select the com port

the portIndex variable must be set to match the com port the arduino is connected to. There was a discussion earlier in this thread on how to check this, have a look for posts with a similar error message.

sorry for the terse reply but don't have much time available for the forums today.  I will be back as soon as I can if you need more help getting this going.

mingki

#494
Oct 20, 2009, 07:27 am Last Edit: Oct 20, 2009, 07:29 am by mingki Reason: 1
Hi, mem. How are you?
I've been checkig the weight of each carriers I made before.
It would absolutely necessary to make each carriers' weight to be equalized so that their weight could be adjusted to zero for detecting only the weight of weight objects.
But, I just realized that the weight of each carriers are significantly different.
This is the weight data of each carriers.
Code: [Select]

              mV        Gram
carrier 1      93      281.8
carrier 2      210      636.4
carrier 3      338      1,024.2
carrier 4      152      460.6
carrier 5      144      436.4
carrier 6      160      484.8
carrier 7      76      230.3
carrier 8      202      612.1
carrier 9      178      539.4
carrier 10      195      590.9
carrier 11      139      421.2
carrier 12      221      669.7
carrier 13      139      421.2
carrier 14      175      530.3
carrier 15      209      633.3
carrier 16      143      433.3
carrier 17      193      584.8
carrier 18      167      506.1
carrier 19      187      566.7
carrier 20      146      442.4
carrier 21      170      515.2
carrier 22      189      572.7
carrier 23      197      597.0
carrier 24      228      690.9
carrier 25      116      351.5
carrier 26      161      487.9
carrier 27      464      1,406.1
carrier 28      215      651.5
carrier 29      179      542.4
carrier 30      141      427.3
carrier 31      177      536.4
carrier 32      230      697.0
carrier 33      218      660.6
carrier 34      347      1,051.5
carrier 35      208      630.3
carrier 36      177      536.4
carrier 37      173      524.2
carrier 38      155      469.7
carrier 39      184      557.6
carrier 40      342      1,036.4
carrier 41      215      651.5
carrier 42      127      384.8
carrier 43      131      397.0
carrier 44      75      227.3
carrier 45      233      706.1
carrier 46      202      612.1
carrier 47      132      400.0
carrier 48      193      584.8
carrier 49      185      560.6
carrier 50      188      569.7

If their weight difference was slight, then I could put some nuts and bolts to balance their weight but as you can see, the weight difference is big.
Is it possible to adjust each carriers weight difference by writing functions in the sketch?

mingkimingki@gmail.com

Go Up