Polymer Recycler


Currently working on the electrical wiring and Arduino control of my penultimate year group project in Design Engineering. We're recycling milk bottles, grinding them up, heating through a screw, extruding, cooling in water and then spooling.

I'm bound to have loads of questions that learned folk like yourselves would love to answer. I have been working on this aspect of the project since early January so it is progressing, I think!

The extruded filament needs to be 2.9mm +/- 0.1mm. We would love to measure this diameter whilst the extrudate is still molten and therefore untouchable. There are a few methods we are exploring but today photodetector arrays have really gotten me excited (would be sad if I wasn't admitting it here :P), more specifically this one: http://www.active-robots.com/products/parallax/tsl1401-linescan-imaging-sensor-daughterboard.shtml

Reading through the documentation I have found I gather that it is possible to digitally read each one of the 128 sensors in the array in turn converting their voltage into a simple 1 or 0.

How does one go about coding this. At the moment I can imagine having an array that is filled by the sensor readings. How do I then inspect the contents of the array to find the edges of my filament? The idea being that then, with some calibration, I would know if the hot filament was currently too big or small in diameter and speed up / slow down the haul off motor accordingly.

Would really love any help with this, be as brutal as you like about it if it's stupid... :D

Thanks in advance!

How do I then inspect the contents of the array to find the edges of my filament?

You step through the array one element at a time with a for loop looking at the values. When you see a transition you make a note of the array element you found it in (set a variable). With an ideal image there should be just two transitions, the difference between the array elements where they occurred is a measurement of your width.

Many years ago I did a project that measured the diameter of a coin rolling down a shoot to identify its value using a very similar method but it was in the years before arduinos.

Thanks very much Mike. It occurred to me in the hours lying in bed struggling to sleep thinking about it, that the array could simply be summed, if the total 1s are greater than some predefined value then the filament is too big, if less then too small, is that simple enough for the Arduino to manage?

I guess I'm going to go do some digging on arrays now.

In terms of parallel or multi tasks. Is the Arduino capable of sampling this photo array often, as well as outputting several PWM pulses? I'm a bit of a newb at all this stuff, but it seems that they wall make use of the crystal and would have a fight over it? What sort of responsiveness could I expect?

Thanks a bunch

Once a PWM signal is set up it takes no processing time to maintain. Even setting it to a new value is just a matter of doing a single memory write. I would imagin the arduino is more than capable of doing this.

yes, lovely! You hit the nail on the head. The aim of the project is just that!
As for the calibration and characterisation I wasn’t expecting it to work straight out the box, but some great ideas there that I hadn’t thought of yet. Brilliant! The sensor was built for these

Parallax’s BS2pe Motherboard but can be used with other BASIC Stamp modules, the Parallax Propeller, the SX, PICs, and AVRs, to name just a few

and comes with a piece of calibration software, I have a feeling that I may have to write a processing sketch to display the output graphically whilst I’m setting up. How simple is that? There’s a tutorial on Arduino <-> Processing sketches so I’ll have me a play.

I think I’m most worried about writing the code that sends a CLK pulse (where’s the clock out pin? just PWM?) to the sensor, and records back the 128 regurgitated values into an array. And then manipulating that array. I think I get the principle but not exactly what to type. Will post my code back when I have it, any help there is more than welcome!

Thanks for your continued help! The news that Arduino is clever enough to not have to tend to it’s PWM signals is great. Once the actual extrusion process is underway the Arduino should be able to:

-Read thermistor
-Read control buttons (about 4 or 5)
-Output HIGH or LOW to heater relay
-Output PWM to extrusion screw motor
-Output PWM to take up motor
-Read the sensor array as continually as possible
-Output some values to a GLCD (including a simple and effective ‘current diameter’ graphic)

Does that all sound feasible?

O and also, actual PWM frequencies. I have been looking at the ‘PWM Secrets’ info about changing the dividers on the timers.
I’ve attached the signal timing diagram from the manual available here http://www.active-robots.com/products/parallax/datasheets/sensory/TSL1401-DB_manual.pdf (I’m a nab and don’t know how to embed images, do I have to upload it somewhere else and then link to it?)

Concern is generating this clock signal and array filling at the moment.

Thanks guys

I think I’m most worried about writing the code that sends a CLK pulse (where’s the clock out pin? just PWM?) to the sensor, and records back the 128 regurgitated values into an array.

Any digital pin can be connected to the CLK pin on the device. Use digitalWrite() to set the pin HIGH or LOW.

I suspect, though, that the Wire library may be able to communicate with the device, and handle the clock and reading for you.

Looked up the Wire library and got to grips with the concept of I2C. Pretty fancy stuff. However it seems the device needs to be able to be addressed in this manner, and after looking through the datasheet for the Sensor, available as attached, I can’t seem to find any mention of this capability.

So it seems it will stay with the notion that i will have to write the code (which seems less and less tricky) that’s along the lines of bashing a digital out as a CLK and grabbing the number that bounces out of the sensor into an array. I think I feel better now that I understand that the clock pulses ‘carry’ the sensor value back. Before I was envisioning trying to synchronise some production rate with a reading rate.

As for calibration, there is a 128x64 GLCD in the project. Plan to have a debug or calibrate option that shows the raw values from the sensor as a bar chart on screen, user then has a horizontal line controlled by a rotary pot for choosing a value that best separates light from dark and hitting enter. For the last value to be remembered, after a restart, would I have to write it to the EEPROM?

There’s a juicy 12VDC ex windscreen wiper motor turning our extrusion screw. Had previously envisaged using a PWM driver board here:
Given that I only need speed control in one direction is this board necessary? Is there some high current transistor or relay or something that could vary with a PWM signal from Arduino that would be more cost effective? That board looks complex for no real reason?

Thanks very much!

TSL1401 Datasheet.pdf (133 KB)

Unfortunately due to the nature of our project we will be unable to know exactly what sort of load the motor will be under until we've pretty much finished. There are numerous complex extrusion calculations, but all aimed at large industrial machines, nothing compared to ours. We are hazarding a guess that we will need to be switching 10 - 15A of current with PWM. A quick google for "15A Transistor" has turned up a few hits. Seems that we would need two or three transistors, each triggering the next. Will that sort of piggy back approach still be PWM controllable?

Looking at using a Dell Power Pack: http://www.overstock.com/Electronics/Dell-D220P-01-Optiplex-AC-DC-Adapter/5542954/product.html?cid=133635

To power this larger motor, a few fans for cooling, and the Arduino. How does one distribute the supply so that if the motor decides it wants to suck all the current out of the power supply it won't turn off the Arduino? I'm looking at voltage regulators at the moment but my electrical experience is somewhat limited.

Thanks for your help!

Makes sense. Thanks.

We're having trouble sourcing a very cost effective power supply with alot of amps in it. That Dell one oddly seems about the best we can get (strict health and safety rules at Uni make it tricky to use more effective power sources like modified PC PSUs). So on that basis can I assume that it can't take more than 15A out of the supply, leavinf 3A for the Arduino, another small motor and a few fans?

I would therefore be looking at something at about 30A like http://uk.rs-online.com/web/search/searchBrowseAction.html?method=getProduct&R=0294429

Would I still be looking at using two transistors in a darlington pair?

How to ensure that the motor can't take more than 15A from the supply? Or should I just power the Arduino and fans off of another wall wart?

Thanks very much for your help!

Haha! Well you’re accent is english in my head, actually it’s strangely like my voice, as if I were talking to myself whilst reading…

The project on the whole has been very interesting, working on it for the last 6 months or so now (wow doesn’t feel like that)

We started from the RepRap http://reprap.org/wiki/Main_Page with some brilliant help from the residents there.

The design is very much all custom built, we are fortunate enough to have 10 hours of professional technician time thrown into our budget by the department. A very very sexy looking variable diameter stainless steel extrusion screw should be coming our way thanks to them.

We are planning on the whole to replicate the open-source ethos that is flying about nowadays, and complete designs will be made available at the end, its the least we can do for all the invaluable help that the world has given us.

I would definitely plan on using a separate power supply for the extrusion screw motor and for the take-up spool motor. And a separate supply for the control system (including the Arduino)

for clarification is that three separate supplies? Will definitely look into the car battery. I can imagine it permanently hooked up to charge?

really looking forward to getting something made now, and programming it…

The wiper motor does have a shaft coming out of the reverse which hopefully I can get hold of an encoder for, nice shout there. Although, simply put, could a resettable fuse be used as a torque cut off, perhaps a warning system could be programmed in that way?

I plan to submit some circuit schematics when I have them done. Would reassure me that the electronics that I have taken on will work, and not cause the whole project to flop on my three colleagues…

Thanks again for your continued support!

Haha, very stereotypical, but his accent isn't far off mine I suppose so I guess that's good. And I do find that advert very funny by the way, o dear.

Anyway, I'm almost there now, well getting closer. We were aiming to power the entire project off of one wall plug, with a standard IEC power cable or kettle cable. Once inside the machine we will need to split the cable to the respective components. I can picture the piece of hardware that would be able to do this but can't be sure I'm looking at the right things.

I'm looking at things like this: http://uk.rs-online.com/web/search/searchBrowseAction.html?method=getProduct&R=3831576]

A DIN rail would be really cool too if there are such components for that? Would need to split the live, neutral and earth to 4 different components.

Also the large transistor that I would like to use to power the extrusion motor http://uk.rs-online.com/web/search/searchBrowseAction.html?method=getProduct&R=0294429 is still worrying me. I have never built a circuit before and although I am fairly confident I can pull of something simple I am unsure as to whether I would need to first switch the arduino current through a smaller transistor, up to like 0.5A or even more?, before making the big jump to 15A? Could really use some insight there.

I'm really pleased with the response on this forum, great place to be. Hopefully when I learn enough I can start putting back in what I've taken out. :D

If you're going with a DIN Rail power system, you're probably going to need some of these as well so you don't upset the health and safety guys (bare power wires into crimp sockets always used to be a nono) http://uk.rs-online.com/web/search/searchBrowseAction.html?method=getProduct&R=0458774

To get the power you're talking about, the power supply is now starting to jump up in price, but still very doable, I'm sure your local RS rep will be able to find you something, a quick daytime phone call to RS Head Office in Corby might also be worth a try as well...

ruled out the power supplies from RS a while ago due to their large expense. Am looking into car or other large batteries and chargers at the moment. I was mainly wondering if there is a DIN kind of system for the connectors / terminals / distributors? That's just because they need to be mounted in some way inside the machine and a DIN rail would be a very attractive way of doing it? i thought so anyway, I have absolutely no experience with designing / making this type of rig, but I've seen a few...

The roof for the 12V DC powersupply budget is about £50 and anything up to or over 20A would be brilliant. Hard to come buy though...

With regards to an experienced someone, there are plenty of academics and technicians knocking about on campus who are more than happy to help. I'll have to run the transistor board by someone. I'm not too against buying the Pololu board, just would be nice to save some budget on it if possible.

eaycrcr: ruled out the power supplies from RS a while ago due to their large expense. Am looking into car or other large batteries and chargers at the moment. I was mainly wondering if there is a DIN kind of system for the connectors / terminals / distributors? That's just because they need to be mounted in some way inside the machine and a DIN rail would be a very attractive way of doing it? i thought so anyway, I have absolutely no experience with designing / making this type of rig, but I've seen a few...

The roof for the 12V DC powersupply budget is about £50 and anything up to or over 20A would be brilliant. Hard to come buy though...

dollars -> pounds cause they're going to clobber you on shipping .. http://www.uxsight.com/product/45579/12v-30a-single-output-lowcost-switch-switching-power-supply.html


saw this sort of thing on eBay. There are some really good deals to be had there, of course. If that sort of style would be a good choice then we may be able to persuade the department to let us buy one from there, they will give us a budget, but we have to purchase from companies that will take a credit card basically.

hmm, we'd have to increase the size of the machine to accommodate it. But otherwise, fantastic!

Was looking into circuit breakers and came up with http://uk.rs-online.com/web/search/searchBrowseAction.html?method=getProduct&R=0854469

I remember it was recommended to go for a circuit breaker and not a resettable fuse, but couldn't work out what category this falls into?

dang! I forgot how much stuff costs back home in the UK... but you should be VAT exempt shouldn't you (being educational buying scenario) ? That in it's own right will get you an additional 20% + buying power

"looks like" that breaker would do the job for ya

You're also going to need cable capable of that type of current as well http://www.powerstream.com/Wire_Size.htm

great link! cable was one of the things I was going to get round to asking about. Right, bed time for today, another day of harassing technicians tomorrow ]:D

Thanks for all your help guys. I will be back often! Hope to get the finished thing posted up in a month of two...!

I’m back!

A few weeks on and my group has passed our critical review and parts have started to be ordered!

I’m playing with my Mega and a 128x64 GLCD at the moment. I can’t work out what I’m missing because I can’t make it just simply display text. I’m using the GLCD library, which is V3 I believe. It seems that this whole print(“string”) ; stuff just scrolls over and over itself so that you can’t read it?

Is there some simple function or trick that I’m missing here?

#include <glcd.h>                   //Include the GLCD Library
#include "fonts/allFonts.h"         //Include System and Arial14 fonts
#include "bitmaps/allBitmaps.h"     //Include all images in the bitmap directory

void setup(){
 GLCD.Init() ;                      // initialise the library, non inverted writes pixels onto a clear screen
 GLCD.ClearScreen() ;
 GLCD.DrawBitmap (RepCycleCLogo64x64, 32,0) ;
 delay(2000) ;
 GLCD.DrawBitmap (ArduinoIcon64x64, 32,0) ;
 delay(2000) ;
 GLCD.ClearScreen() ;

void loop() {
  controlPanel() ;

void controlPanel(){
  GLCD.SelectFont(System5x7, BLACK) ;
  GLCD.print("Hello World!") ;

setup works very well, and I love the way my little logo looks. Just having problems with displaying text. The GLCD will form the basis for User Interface, selecting whether to Shred or Extrude or Calibrate the photodiode array etc. but I can’t get on to writing any of that stuff until I can happily produce a string that stays where I put it… haha!

Any pointers on this topic would be very helpful,

Thank you very much!

Just as I suspected, I was looking at using some IFs to just run it once and then wait for something to happen to move it on (pressing a button). The worrying thought is though that the example Sketches for the GLCD library don't use such seemingly unnecessarily complicated routines?

.....was going to link to code that shows this, but of course you're spot on again mate. They use the GLCD.CursorToXY() function before printing!

OK brilliant!

onwards and upwards (perhaps). I'm planning on writing text to only a few places on the screen at a time, like you would to produce a Menu. Is there a short and funky way that I can define several positions at the start that make my code neater in the long haul?

So instead of:

GLCD.CursorToXY(GLCD.CenterX, GLCD.CenterY) ; //etc.

I can get something like:

GLCD.CursorToXY(TOP) ; GLCD.CursorToXY(1) ; GLCD.CursorToXY(2) ; GLCD.CursorToXY(3) ; GLCD.CursorToXY(4) ;

or am I just being greedy now?

Thanks as always for your help!

Don't worry about that one, I've just realised that (as the guidance documents do say) I can use the cursor placing function within a text area. So can use text areas without the crazy scrolling text so can achieve the easy position reference that I was after.

I've started drawing down proposed wiring diagrams (different coloured pen lines on printed out dot matrix) to figure out how my strip board "shields" will go together. Is it possible:

To solder a wire straight to strip board? Split the strip between two holes? (for a double row header)

And probably impossible to answer without showing you my lame drawings, are there any common pitfalls I should watch out for? I saw a post you made about decoupling, should I cater for this?

I have:

A GLCD Several Push Buttons (pull down resistors) 2 Rotary Pots 3 NTC Thermistors 1 Photodiode array 1 12v 0.3A Motor 1 12v 15A Motor 2 12V Fans 5 12V LED Lamps

so a 9V Walwart for the Arduino, which will power sensors and GLCD and a 12V source for all the stuff that says 12V infront of it. Do these two sources need decoupling further than the Darlingon Transistors with Flyback Diodes or Pololu Motor Driver that I am using?

Hope that makes sense... just starting to feel more confident about some things.