Loading

Hey! This thing is still a Work in Progress. Files, instructions, and other stuff might change!

Filament Width Sensor Prototype Version 3

by flipper, published

Filament Width Sensor Prototype Version 3 by flipper Sep 7, 2014

Use This Project

Give a Shout Out

If you print this Thing and display it in public proudly give attribution by printing and displaying this tag.

Print Thing Tag

Thing Statistics

49625Views 9430Downloads Found in 3D Printing

Summary

This is a prototype for an optical sensor that measures the width of plastic filament in real time as it goes into a 3D printer or a filament extruder. It is prototype #3 (other 2 are on Thingiverse as well ).
The idea is that with a real-time width measurement the 3D printer could compensate the extruded flow for changes in filament width. Also if there is variation between spools of filament, there is no need to calibrate for that when slicing. The g-code is independent of the filament diameter. For filament extruders, the measured width can be used as feedback in the extrusion process.This version includes a custom designed pc board as well as a housing. A version of Marlin is modified to use the sensor data.
The sensor outputs a voltage in milimeters (3v=3mm) that is shown on the voltmeter.
I made some changes to Marlin to read the filament diameter real-time and compensate the extrusion rate. Code uses a buffer to manage the transit delay between the sensor measurement and the nozzle.

This prototype sensor is compatible with the design of the latest Lyman extruder. I worked with Hugh on building the controller and incorporating the sensor into the system.
http://www.thingiverse.com/thing:380987

Updates in version 3: I improved the PC board to use screw terminals for the connections. I removed the unused components. Board has the same dimensions as previously. There are two case designs, one for 3D printers and one for filament extruders. The same PC board works in both.

Update9/21/16 - I updated the firmware so that either a 1.57mm and 3.00mm calibration rods can be used to calibrate the sensor. Firmware will self-detect which you are using.

There is lots of relevant discussion at the prior version sites:
Version 2:http://www.thingiverse.com/thing:89044
Version 1:http://www.thingiverse.com/thing:70775

I am selling a limited number of pc board kits at:
http://objectswithintelligence.weebly.com/store.html

The main branch of Marlin now has initial support for the sensor. However, it does not have LCD support (yet - pull request was submitted). You can findthe version with LCD support at https://github.com/filipmu/Marlin/tree/Filament-Sensor

Here is a video of how to make the sensor work:
https://www.youtube.com/watch?v=5JmroyGb4qY

Instructions

First Decide if you want a sensor for 3D printing or Filament extrusion.
Procurement


  1. Get the PC board made.
    • See Seeedstudio_order_v2.0.zip for files needed to order a board from Seeedstudio. The specs are on the PC_board_BOM.pdf.
    • Alternatively, use the EagleCAD files to order from somewhere else. PCB thickness is critical in the design to ensure case closes. Should be 1.6mm as listed on the PC Board BOM.
  2. Order parts from the BOMs (PC Board and either the Extruder_version_BOM or Printer_version_BOM)
    Make the Case Parts
  3. Print out the relevant parts (Printer or Extrusion .stl's) in ABS with 20% infill, .5mm nozzle, .4mm layer height.
  4. Paint inside of tower and top plate sensor area with flat black craft paint (reduces light reflections).
  5. Drill out the hole in the tower to fit an LED (if needed) using #9 (0.196inch) Drill out the screw holes in the top plate with a #50 (0.07 inch) to allow the 2-56 screws to self-tap.

Make the Electronics


  1. Use solder paste in a syringe and an electric skillet to reflow solder the parts to the PC board. See http://www.instructables.com/id/Simple-Skillet-Surface-mount-Soldering/
  2. Check the PC board with a meter for solder shorts and fix them.
  3. Solder two 4 inch wires to the 5mm through-hole LED that will be put in the sensor tower.
  4. Flash the MCU using http://www.evbplus.com/freescale_usbdm_osbdm/usbdm_osbdm_bdm_multilink.html.
    • If all you want to do is load the firmware on the mcu you can use the software that came with the programmer board (USBDM board). If you install the drivers, it installs some flash programmer software, one called HCS08 Programmer. This software lets you load the compiled firmware 'hex' file (called FilamentSensorproto2.abs.s19 in the directory called FLASH in the zipped project Freescale_8_bit_code_04042015.zip) into the MCU. No need for the IDE in this case.
    • If you want to open the code in the IDE, see the dev tools for free from freescale: freescale.com/webapp/sps/site/overview.jsp?code=CW_SPECIALEDITIONS - look for the one for microcontrollers, eclipse version.

Final Assembly


  1. Use ABS juice to glue the tower onto the top plate using the attached photos as a guide. Hole in tower should line up with hole in top plate.
  2. Print out the Case_labels.pdf on an injet printer and cut out the label to paste on the back of the case. Glue with ABS juice. Can let ABS juice soak in to the paper.
  3. Press the PC board into the printed Base Plate. Make sure it fully seats against the standoffs (use an exacto knive to clear plastic)
  4. Push the Top Plate assembly onto the Bottom Plate (they should mate) and fasten with the 2-56 screws (3 for extruder version, 4 for printer)
  5. Attach the LED wires to the +An and -Cath screw terminals. LED has a flat on the -Cath terminal side.
  6. Insert the LED into the tower (should fit gently) and screw on the ABS Cap while holding the leads in place.

Testing and Calibration


  1. Connect a voltmeter to the 'Out' terminal and 'Gnd' terminal.
  2. Provide 5 volt power to the correct terminals (I use a USB charger and cut-off USB cable)
  3. LEDs should light up and voltmeter should read below 1v.
  4. Place a piece of calibration rod (either a precise 1/16 in drill rod OR a precise 3mm rod) in the sensor and gently hold level and down. - Voltage should show >1volt. Press and hold the button on the sensor for >3 seconds - indicator LED will go off and then on when complete.
  5. Output voltage should show 1.56 volts, assuming power voltage is exactly 5.00 volts. Can press button <1 sec to switch modes to absolute output to confirm calibration. - see Board_instructions file for more details.

Attach the Sensor to 3D Printer or Filament Extruder


See Filament Extruder thing for instructions for Filament Extruder:
http://www.thingiverse.com/thing:380987

For 3D Printer:

  1. Connect the sensor to an A/D input and +5v power on 3D printer control board - see 3D Printer_hookup.pdf file.
  2. Download the latest version of Marlin from Github (official release v1.0.2 has filament sensor support when I wrote this) https://github.com/MarlinFirmware/Marlin.
  3. Change the Config file as needed for your printer. There are some new defines for the filament sensor in this code.
  4. Upload firmware into your 3D printer.
    Using the Sensor with your Extruder or Printer

    See Filament Extruder thing for instructions for Filament Extruder:
    http://www.thingiverse.com/thing:380987

For 3D Printer:

  1. Add custom g code to your slicer software to enable sensor:
    M405 ; turn on filament control
  2. While printer is idle you can see the filament sensor reading by keying in and sending an M407 to your printer. It will return the diameter to the log.

See the following video for more info on construction and usage: https://www.youtube.com/watch?v=5JmroyGb4qY

More from 3D Printing

view more

File Name

Downloads

Size

All Apps

This App connects Thingiverse with Makeprintable, a cloud-based mesh repair service that analyzes, validates and repairs most common mesh errors that can occur when preparing a 3D design file for p...

App Info Launch App

Kiri:Moto is an integrated cloud-based slicer and tool-path generator for 3D Printing, CAM / CNC and Laser cutting. *** 3D printing mode provides model slicing and GCode output using built-in...

App Info Launch App
KiriMoto Thing App

With 3D Slash, you can edit 3d models like a stonecutter. A unique interface: as fun as a building game! The perfect tool for non-designers and children to create in 3D.

App Info Launch App

Hello Flipper, I want to use a 2mm diameter to calibrate the sensor, I install the freescale ide,
I modify the main code, but I don't know how to compile the source
can you help me please ?

4 days ago - Modified 4 days ago
flipper - in reply to tthomas52

I assume you have the eclipse based IDE. Take a look at the quickstart guide, starting from Section E - debugging your application.

http://www.nxp.com/files/soft_dev_tools/doc/quick_ref_guide/MCU_QS.pdf?fasp=1&WT_TYPE=Quick%20Reference%20Guides&WT_VENDOR=FREESCALE&WT_FILE_FORMAT=pdf&WT_ASSET=Documentation&fileExt=.pdf

It shows how to build and debug. Do you have a programmer like this one?

https://www.fasttech.com/reviews/1003400-usbdm-osbdm-v4-95-freescale-usb-emulator

It works with codewarrior IDE and has been used by others to program the firmware on the sensor board.

yes I have this programmer
thank for helping

Sep 6, 2016 - Modified Sep 6, 2016

Flipper other than the 3 mother boards listed in the Config.h file of marlin... is there a list or forum post or any source with details of other 3D printer motherboards that people have successfully configured your sensor?

I have been commissioned to build a high end 3D printer in house as a teaching project, so money is not an issue and I want to see what my options are.

As far as I know there is not. Its generally a matter of finding an unused analog input on the board and then changing the pins.h file in Marlin to make the new pin available to the rest of the code.

Thanks fr the reply. I will be trying to set this up on a Aus3D Rumba+ board in the next month... I'll report back my settings if it works out.

Hi flipper,
Is there a chance to sell some of this sensor in the future ?

Yes I will have more available in the store in a week or 2.

Hello Flipper
I have built this sensor and calibrated it using a 2.99 mm rod and when I measure the voltage output out of the sensor (with the rod inserted and steady) it shows the correct measurement (it oscillates between 2.98 and 2.99 V) showing that it works just fine and everything should be alright with calibration, the board and the printed case.
However I'm using it with the filament extruder V5, the LCD readings are oscillating so much anywhere between 2.64 mm to 3.83 mm. I measured the aux 2 pins of the ramps board and its supplying 5V as well and the signal going into the RAMPS board is the same as the one measured right at the sensor terminals (2.98 - 2.99 V).
I don't have much knowledge of programming but I'm trying to figure it out, I suppose some oscillation is expected but not of that magnitude.
Do you have any clue what it might be ? or what should I look for or add into the mackerel code ?
Thank you for your time.

Hello Flipper.
I thought i would build this and try it out, but i can't find the correct "MC9S08SG8CTG" on ebay, ali-express or mouser. There are a lot of other modelnumbers, like : MC9S08SE8CTG or MC9S08QG8CDTE. Some have 20pins, some 16, some 8, very confusing.
But which one are compatible?

Looks like the model number changed. Its S9S08SG8E2CTG.

I have installed mine onto a PICA revB board (http://community.reprapwilson3d.com/t/i-designed-a-new-rendition-of-ramps-called-pica/167) which runs a forked marlin 1.0.4 by mjrice (https://github.com/mjrice/Marlin) I am running 1.75 filament and although I have calibrated it and set all my parameters I am getting 2.2 as my dia when connected to the MB using pin 12 which was a temp in pin.

If I disconnect the Out pin I get the proper size aprox 1.5v on my multimeter but as soon as i connect it i get 2.2v. I have run a print and watched the filament being measured but in the 2.33 range. the factor is always 100% and never changes.

I am in contact with the board maker (Mjrice) and waiting a reply but is there anything else I should try in the meantime... anything obvious from what I am describing here?

It sounds like either the pin on the PICA is not configured as an input or it has too low input impedance. The sensor board expects an input impedance greater than 5k ohm or so.

fiipper thanks for the reply I'll put this to mjrice and see if he can come up with a "work around" for me.

May 30, 2016 - Modified May 30, 2016

Does anyone know if this is possible with a MKS based Board? If yes: how it´s been cabled ?

hmmm I know that, optical mouse has a tiny camera. is it possible to use that sensor?
https://www.youtube.com/watch?v=bci7Gi05BNc

Great project and I received a board from you to experiment with.

I'm working on a prototype design and I want to firmly mount the sensor enclosure onto my carriage in a single print (potentially)

Is it possible to get the source files for the "For Printer" version of the case? I can figure out something if that's not something you're comfortable with.

I'm also trying to understand the "//measurement delay in cm. This is the distance from filament sensor to middle of barrel" and the "middle of barrel comment". Is this the nozzle tip or the middle of the extruder hobb? My inclination is the former but if you happen to know I'd appreciate it. I'll edit this if I find the answer

I saved the CAD files out in the "Thing Files" See the two zipped folders. One is labelled printer. The CAD files are for a program called Cubify Invent. It might be similar to Alibre.

As the solid filament enters the 3D printer extruder heated barrel it liquefies somewhere in the extruder barrel before coming out of the nozzle. It is at that transition point (right before it melts) where the filament cross section acts as a piston and pushes the liquid plastic in the barrel and out the nozzle. The cross sectional area of the filament at that point is effectively the size of the piston and so is the key variable we want to measure. My guess is that this occurs somewhere in the middle of the barrel before the nozzle tip.

Awesome thanks. Are you aware of anyone using your device as a filament runout sensor? Seems to me you could use a parallel circuit to look for low voltages (<1v) and go low triggering the filament change alarm in marlin

Here is a new simpler filament extruder controller made by Anthony that uses an arduino board and a low cost motor driver to control a brushed DC motor. http://www.thingiverse.com/thing:1454222. He is looking to use it to re extrude plastic bottlecaps.

ulletjes extruder

Good afternoon!
I have successfully assembled filament sensor that outputs a voltage proportional to the diameter - 1 mm - 1V.
But there is a problem in Marlin.

The "MEASUREMENT_DELAY_CM" works with a value of up to 5 cm.
Moreover, during operation, the delay time randomly varies from 1 cm to 5 cm.
And I have a "Bowden" - 69 cm !!!

Marlin - 1.1.0-RC3 - 01 December 2015 (the only version, which once earned the sensor).

Please, help!
I apologize for bad English.

This is great! I am very excited for this project. The possibilities of using this with self extruded filament made this a big winner for me.

We've built our own boards exactly per the specifications. Out of the 3 we made, one doesn't work. BUT two of our boards have the green indicator lights and are detected by the USBDM-1-JS16. We can erase, but when we try to load with get the message: "Verify Failed" Verfication of the target flash failed. Reason: Program Data Not within target Flash Memory

Can someone help us as to what is going wrong?

I have never seen that message. Maybe you selected the wrong target device in the programmer? Should be MC9S08SG8.

Stupid questions: how does this handle oval filament profiles? How does it handle clear or semi-clear filaments?

I tried clear PETG: currently not working for printing.

Hello! Mr.flipper,Can you tell me how to change the calibration data in the source program,Because it is difficult to find the things diameter which is 1/16 in, 1.57mm, Thank you! I am looking forward to your reply ~!

Jul 25, 2015 - Modified Jul 25, 2015
flipper - in reply to a920496044

The latest version of the firmware available here does this already - look for Freescale_8_bit_code_032015.zip. With this firmware, the sensor can use either a 1/16 in drill rod OR a 3mm rod for calibration. The firmware can detect the difference at calibration time.
If you want to change to other rod sizes besides 1/16 or 3mm, look for the following #defines in the code:

//These defines set the two types of calibration rods that are possible to calibrate the sensor with

define CALIB_STANDARD_A 6329 //calibrate using a drill rod of .062 in diameter (1.57 mm) set to (1.57 mm)(15.748 pixels/mm)(256 fp)=6329

define CALIB_STANDARD_B 12094 //calibrate using a drill rod of 3mm set to (3.00 mm)(15.748 pixels/mm)(256 fp)=12094

define CALIB_STANDARD_THRESHOLD 9211 // Threshold for automatically determining the size of the calibration rod based on inherent sensor accuracy.

The comments give the formulas to convert the rod size into pixels into the fixed point number format used in the firmware (floats are for babies :^) ). Note that the rods need to be substantially different sizes so that the sensor can detect the difference based on a threshold.

Jul 29, 2015 - Modified Jul 29, 2015
a920496044 - in reply to flipper

Hello,Mr.Flipper ! Thank you for your reply , but I have little problem.......which file can change those parameters ? And I still have another problem,according to the 【LYMAN_MULIER_FILAMENT_EXTRUDER_V5_MANUAL_R1.pdf】,the Filament Width Sensor have two mode, ratio‐metric mode & absolute voltage mode, I try to press the button to change the mode ,but nothing happened ,whether it is because my standard parameters is fault ? this is weird ,can u tell me? thank you ,Mr.Flipper ^-^

The file is Filament Sensor proto2\Sources\main.c. Yes there are two modes by pressing for 1 sec or less. I am not sure why its not working for you. I am guessing it might be a hardware issue, assuming the flash programming worked fine. Is the LED on the board working? It should flash after pressing the button for a second or so.

Any Repetier Firmware possibilits?

Congratulations. Very nice project.

I am sure it is possible, but I think my head will explode if I try to figure out how Repetier firmware works in addition to Marlin. It took me about 6 mos to figure out Marlin enough to make changes, and its a constant effort to stay up to date on the Marlin code base. Here is how I would approach it though:

  • find the code where the extruder temp is read from the A to D converter and use the same design to read the filament sensor on a free A to D channel.
  • find the code where each gcode extruder command is converted into the stepcount for the move and insert a factor based on the filament diameter like (expected_dia/measured_dia)^2 so that the stepcount sent to the move planner is modified.
  • find where the gcode text commands are interpreted and add some new mcodes so that you can turn on/off the filament control and modify its behavior.

If you can get that to work, then refine by adding the ring buffer to handle the filament transit distance (distance from where the sensor measures the filament to where the filament melts in the barrel).

I removed all smoothing code from the mackerel firmware and then placed a piece of filament in the sensor. The reported width always fluctuates 0.11mm (3.20-3.09) Is there a way to improve this?

It's mentioned somewhere in this thread that the sample rate is 100hz but the output is only updated 1/sec. However when extruding (for example) 40mm/s then averaging those 40mm might mean that it is possible that a long piece of filament with a diameter larger then 3.1 will not be reported (averaged out) but when using that filament it will block the 3d printer extruder. Is it possible to improve the 1/s update rate?

Found the source of the 0.11 fluctuation (I think). Ordered some parts to test my theory.

The 100hz sample rate I could not find in the source , I could only find a 5Hz sample rate. ctrate =2 (that is the time period between samples in 100ms) ?

Aug 16, 2015 - Modified Aug 16, 2015
CFTechno - in reply to CFTechno

For those that want to test that 0.11mm fluctuation. I have connected the sensor to a aduino and wrote a very short sketch.
[code]
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// print out the value you read:
Serial.println(sensorValue,DEC);
delay(10); // delay in between reads for stability
[/code]
I collected around a 1000 samples while a piece of filament was placed in the sensor. This is the result:

http://i18.servimg.com/u/f18/13/37/93/48/sensor10.png

The black line is a 32period moving average.

I think what you might be seeing is the ripple in the output due to the D to A converter. The circuit uses a simple pulse width output and some filtering to produce an output voltage. The output has a .1v ripple at 16.6kHz. See the two photos of my scope traces:
http://thingiverse-production-new.s3.amazonaws.com/renders/20/ae/58/14/bb/output_ripple_1_preview_featured.JPG
http://thingiverse-production-new.s3.amazonaws.com/renders/85/fb/ef/f4/93/output_ripple_2_preview_featured.JPG

I would use some additional low pass filtering to reduce this ripple before sampling at the rates you are using.

The ctrate parameter affects the overall sample rate. The code comment is incorrect, the max sample rate is 256 Hz for the interrupt counter, so a ctrate=2 would give a 128 Hz sample rate. There is a simple lowpass filter in the code (an exponentially weighted moving average) that has a filter param widthfilterparam = 5. That is 5/256=.01953. See http://gregstanleyandassociates.com/whitepapers/FaultDiagnosis/Filtering/Exponential-Filter/exponential-filter.htm On this site a param a is used where a=1-.01953 to relate back to the filter in the code. This results in a time constant of roughly .4 sec. You could change the widthfilterparam to a larger number to reduce the time constant. This will result in a faster sensor output.

Thank you! That info pointed me in the right direction :-)

Might still not understand it completely but if the time between samples is 2/256 and widthfilterparam =5 is it then not 10/256 (0,0391) ?

Minor questions

  • did you profile the main routine? In other words is it fast enough to be executed within the 1/128 second? If you did not profile it, no problem I will try to do it.
  • why the lowpass filter? Did you see weird values sometimes? With other words is there really a need for the filter?

The parameter widthfilterparam does not affect the time constant linearly - see the link for the formula that relates the widthfilterparam to the time constant. If you don't want to mess with formulas, you can change it and see what happens - the range is 255 - will provide no filtering, 1 - provides longest time constant.

I did not profile the main routine, but I did some tests where I added debug I/O so that a high pulse was output when the main loop finished and also when the interrupt started and confirmed that the main loop ran with time to spare within the interrupt cycle.

Lowpass filter was there to avoid customer support issues where casual users might assume there is a problem if they see the output vary constantly. I suspect that some filtering is needed but it probably can be reduced.

If the sensor is 400dpi, that works out to 15.75 pixels of resolution per mm, or 0.0635mm/pixel. Is there some sort of supersampling that takes place to increase the resolution? Because it seems that 1 pixel of resolution means it is either 3.00mm filament or 3.0635mm or 2.9365mm which would be a pretty giant difference for just one bit which I'd expect is within the domain of error in the sensor.

Testimonials of users indicate the device works, but how can just 1 pixel effectively tuning the extrusion multiplier 2.1% one way or the other be accurate?

Yes, as inornate says it uses interpolation between the pixels, which gives an accuracy of about .02mm with the sensor in practical use.

But the shadow casted by the led on the sensor doesn't cover the full sensor so only a small part of the 128 pixels is used to measure the diameter, so the smaller the shadow the larger the error. I think it would be improve the data if there was an option to increase the distance between the filament and the sensor depending on the thickness of the filament, it would improve the precision of the measurement.

Some screw system to increase/decrease distance and the calibration routine notifying the user as soon as 90% of the sensor is covert by the calibration rod shadow. Two issues with this

  • The calibration rod must be equal to the desired filament diameter
  • If the filament is more then ~ 11% larger then the desired diameter the sensor will not be able to measure the real diameter. However that 11% would already make the filament unusable for 3d printing as it will block the nozzle.

Wow, that's incredible! I mean the results clearly speak for themselves, but I was just curious how it could work given the precision of the sensor. Thanks for the explanation, and really great idea!

There're sub-pixel interpolation feature.
I migrated this code for Arduino, and for sure there it was.

What is the difference between Absolute and Ratiometric? If Ratiometric is not sending an absolute voltage amount equal to the measurement, how is it communicating the value to the printer controller? I can see that with absolute, you are using the bandgap to determine the actual source voltage so it can set the PWM correctly. Is ratiometric assuming the source is 5V, and not something close like 4.8v?

The printer controller's A to D input is ratiometric. In other words, it measures the input voltage relative to the supply voltage. So if the filament sensor is set to ratiometric, it is also relative to the supply voltage, in effect cancelling out the impact of varying supply voltage, or a supply voltage different from 5v. For example, In ratiometric mode, the sensor outputs 50% output for 2.5mm and 100% output for 5mm. If the supply is 5v then its 2.5v and 5.0v out. If the supply is 4.8v its 2.4v out and 4.8v out. At the input of the printer controller, an input of 50% is interpreted as 2.5mm and an input of 100% is interpreted as 5mm.

Jun 1, 2015 - Modified Jun 2, 2015

Hello~ Mr.Flipper , why I can not found the BKGD port in the PCB board ? How the firmware upload to the chip ? By the way ,happy children day ~! :p

See the holes for a 6 pin header below the push button switch. A header can be soldered in to connect the programmer. Alternatively, you can use spring loaded contacts to program (what I do).

Jun 20, 2015 - Modified Jun 20, 2015
a920496044 - in reply to flipper

hello,I have a problem about Lyman FILAMENT EXTRUDER . I had connected the thermistor,but it cant work .On the LCD, it display 0°C. And my thermistor is MF58 100K, I m also set the thermistor mdel is 9 in the Configuration.h . But it is still cant work. Can u tell me why ?Please T-T.And i m also want to know how to set the setpoint temp,Can u tell me? Please ,Thanks

I posted an updated firmware. The only difference is that now you can calibrate the sensor with either 1/16in (1.57mm) drill rod or 3.00mm drill rod. The sensor can tell the difference automatically. The new firmware is called Freescale_8_bit_code_032015.zip

Thanks for making and sharing your design. I've seen the work you and Wane Kinne have done with the dual sensor V5 filament maker. Do you have plans to release the modified firmware with the PID tweaks? I'm building a V5 and would like to make it a dual sensor with Teflon die.

Yes, the code is out on github. It is a version of Mackerel that supports a second filament sensor ('blob' sensor) positioned right after the extruder. It has a second PID loop that is adjustable via the LCD menus. The LCD will now show the blob size where it previously showed the min/max (you should see ‘b3.5’ there indicating blob size) This is very experimental with limited testing. Note that it will wipe out your existing settings saved in eeprom and will start with default settings. You might want to jot down any existing settings you changed before installing it. This is because I added all the new PID params to the eeprom to allow them to be saved.
https://github.com/filipmu/Marlin-Mackerel/tree/Experimental-Die

I've found that this control might be helpful for controlling the extruder, even without a teflon die. Also, there is a repetitive pulsing in the extruder output that matches the screw RPM. I've wanted to update the code so that it is able to change the extruder speed within each rotation to compensate and smooth out the pulses.

The filament sensor (puller control) is hooked up to the original place on the RAMPS. The blob sensor now needs to be hooked up to a new input. Attached is a picture of where to hook it up (called RAMPS wiring and instructions with blob sensor.pdf. Note that its hooked up to AUX-1 and pin configuration is different.

Hello Filip, could you take a look to this post on the reprap forums on how the auto adjusting feature in Marlin works? http://forums.reprap.org/read.php?70,475206,504449#msg-504449

flipper - in reply to zasf

See my comments on that site.

This comment has been deleted.

I dont understand how you can get usable data when you only measure the width in one direction.

Is there some math voodoo going on we dont know about?

And In practice are there any improvements to your prints?

Some before / after pics would be interesting.

It just assumes the filament is round like a circle.

I'm not the designer but it has improved my prints with some filaments. As an added Bonus, I can print some of my filaments with the same gcode without any adjustments.

Apr 18, 2015 - Modified Apr 18, 2015

Hi, I just ordered 2 of these and have installed the first one on my printer. Everything seems to be working except when an item is printing the status of the sensor flashes on my LCD so fast I can't see what it says. I'm using the full graphic controller. My flow rate also stays at 100% no matter what size the filament is. I can manually feed and see the mm range of 1.69 to 1.76 but flow rate stays @ 100%. Set at 1.75mm in my slicer. I've change the start code to include M405.

//When using an LCD, uncomment the line below to display the Filament sensor data on the last line instead of status. Status will appear for 5 sec.

define FILAMENT_LCD_DISPLAY

That last line doesn't seem t be working as I see the status of the print itself and only see sensor status for brief flashes. To fast to even read.

Thanks
-Kevin

Hello,

Flipper a great job what you have make.
But can some one tell me where to buy the mc9s08sg8ctg in Holland.

Hello, Flipper. Many thanks for your excellent work on this project. I've printed the housing and received your pre-built kit via Storenvy, which was a real time-saver. The device works swimmingly, with one caveat (isn't there always one?) that I would appreciate your insight on. I can measure a minimum diameter of my series of gage pins of 0.93mm before the reading drops to zero. Anything smaller than .037" or so seems to disappear to the sensor. Again, I'd appreciate any guidance you could give me on getting this reading down to lower diameters. Ideally, I'd keep on seeing down to around 0.25mm... Thanks, Flipper.

The firmware is set up to output 0 volts for any signal less than 1mm. That is to avoid spurious output when there is no filament in the sensor. I am not sure if 0.25mm will cause spurious outputs.

Is there an easy way to get ramps 1.4 to have gcode fan control and this filament sensor, any progress on multiple extruders?

You should check the Marlin github site for your first question. I am not aware of any multiple extruder setups.

Apr 3, 2015 - Modified Apr 3, 2015
burtdonalds - in reply to flipper

Thanks for the reply and great work again!!! I already checked and it's gonna require some code changes to use marlin's current method (don't have time personally) for automatic control if at all with my current ABL servo (will be gone soon I am moving to a induction sensor also then I could just use http://www.geeetech.com/reprap-ramps14-rrd-fan-extender-p-683.html) but honestly I don't even think I need the gcode fan in its current implementation since my i3 with ANC, ABL, firmware retracts, good calibration, and the filament sensor giving me near perfect extrudes seems to have made it so I can easily print working gears at really sparse to no infill;(my 2 year daughter can break them apart since it is 1 layer on the bottom with a very slight distortion) and even the NASA wrench is now working with ease...I'd even switch filament 50 times; and still know the print will still be spot on to near perfect. I'm using it with my custom unreleased bowden setup with 52CM of ptfe between the sensor and center of the nozzle and it still works very well at even 350+MM/s extrudes (didn't paint the case either).

Is there any patent challeges about this idea ?

There are no patent challenges.

I posted an stl file with a slight design change for 3D printers using 1.75mm filament. The hole that the filament passes through is reduced in this part. Its called "Sensor top plate printer 1.75mm version v3.stl".

Where can i get V3b of the software?

The latest version of the software is already posted in the Thing Files - Freescale_8_bit__code 06012014.zip http://www.thingiverse.com/download:759615 . There is no version 3b.

Does it output filament diameter in analog voltage or is it a digital output to the printerboard in the printerversion?

Its an analog voltage output. The printrboard (or RAMPS) reads the signal using its A to D converter.

Jan 15, 2015 - Modified Jan 15, 2015

I ported an Arduino version of this sensor.
Check out http://www.thingiverse.com/thing:636420 and any feedback would be appreciated.

Filament Width Sensor with Arduino Pro Micro and TSL1401CL

I was looking into making one of these but in the files you have uploaded here the pcb files for seeedstudio are for version 2.0, is this the correct files for v3.0?

Yes they are correct. PC board is on its own versioning scheme.

Mar 24, 2015 - Modified Mar 25, 2015
ahmedx - in reply to flipper

I order PCB but I've made a mistake and sent the wrong file v 1.1 :(
I have now a PCB version 1.1 Can it work with v3 ?

Both boards have the same outer dimensions, so they fit in either case. The only difference is the newer design has screw terminals. The design you have has solder terminals on the board.

Oh i see its kind of like v3b :P , thank you.

Nov 5, 2014 - Modified Nov 6, 2014

Can't wait for a version that takes into account the fact that filament is never exactly round.
Maybe you could use two leds at 90 degree that emit different wavelenghts and use filter with the sensors so they see only one wavelenght each. Dont know much about the subject (or if its even possible) but I'm sure there is someone with the proper knowledge out there that could give us a few hints.

How fast can it read the diameter? Will it be able to accurately measure filament up to 50ft a minute?

The sampling internally is about 100Hz, but the output has some averaging at roughly 1 sec time constant.

Hi Filip

Is there any problem with printing the housing out of Black ABS and therefore I can skip step 4

4 Paint inside of tower and top plate sensor area with flat black craft paint

Regards
Paul

I would think black ABS would work fine.

3D prints dont appear shinny beacause of all the layers but if you look closely each layers are indeed shinny. Wouldnt this cause issues?

Here is a guy who made one using black abs: http://www.binaryspace.co.za/?p=345 If it behaves erratically, you can always paint the black abs with flat black paint.

zasf - in reply to flipper

I'm using black PLA and have no issues. I made a Arduino Mega version with display, see http://www.thingiverse.com/thing:668377

Filament Width Sensor - TSL1402R + Arduino Mega (Work-in-progress)
by zasf

Can this be made to use 1.75mm filament

Sensor board would work with 1.75mm filament, but the enclosure case would have to be modified. You would need to reduce the size of the hole from 3mm to 1.75.

I'll take a look into programming the MCUs before they are soldered. I think there are special holders for that to attach the programmer to the leads. These MCUs are moisture sensitive so I need to check how to handle them after them come out of the pouch with desiccant. Maybe they can be re-dried somehow.

As for calibration, I think I can make the firmware detect the calibration rod (english or metric), because the difference between the 1/16 in. (.157 mm) and say a 3mm rod is large enough to detect from the raw sensor reading. I can get 1/16 in. drill rod with .0003 in. (.008mm) tolerance for pretty cheap ($1 for 1 meter length). Is it possible to get 3 mm drill rod with good accuracy (.01mm)?

You can find a precise 3mm rod in almost every retired (and new) DVD-drives. I found one with 2.995mm ...

Sep 13, 2014 - Modified Sep 13, 2014

Thanks for continuing the development. I really like that you added a buffer functionality, it is now possible to use it with a bowden extruder system.
An idea: Is it possible to use either an imperial calibration (as it is now) or a metric one? Most people in europe will have metric drills lying around (1mm, 2mm, .. ) but not imperial ones.

As Green Rider said, it would be really nice to get at least the programmed MCU and the PCB from somebody (although I can order the PCB myself, the programmed MCU not so much).

Dear flipper,
This is a very nice project and I would love to add it to my 3D printer but, buying a programmer and learning to use it with an MCU that I have never used before is too much work for one time project.
If you will make a kit with PCB,parts,MCU(already programmed), I think people would buy it (I will).

Think about it :)

I took your advice and made a few kits. You can buy them at: http://owi.storenvy.com/

I bought your kit but i am also making a few more for my dual head and my Filament extruder, my question is in order to flash the MCU all i need is the USBDM correct? Just want to be sure i dont need the Dragon12.

Thanks

I received my Sensor today and hooked it up, I calibrate it and it reads 1.55mm all good right ,,, when i slide a 3mm piece of filament it reads 99 or less, it is like it is reading backwards. any suggestions?

Yes, you just need the USBDM-1-JS16 and hook it up to the 6 pin port on the sensor board labelled BKGD. This page http://www.evbplus.com/freescale_usbdm_osbdm/usbdm_osbdm_bdm_multilink.html has instructions. You will follow the instructions similar to 'Programming example #1" using steps 2-6. Use the HCS08 Flash Programmer (not HCS12 flash programmer as shown). The processor used on the sensor is an 8 bit 9S08 called 'SG-MC9S08SG8'.

The dragon board is a 16 bit HCS12 dev board which you don't need. I guess the USBDM can also be used to program that.

This comment has been deleted.

I am not getting a reading from the output, When i try to calibrate it will not. I have done all your tutorials and it still will not work. Any help will be greatly appreciated.

Sorry for the delayed reply - my internet went out for a few days. I have some questions to help us diagnose the problem. What application is it for a 3D printer or a filament extruder?. Are you using a voltmeter to read the output or a controller board? I assume you did print out a case and paint the inside with black paint? I assume your filament is not translucent? Is the LED in the light tower illuminating? One thing that may happen is that if you calibrate and not have the metal rod held down on the sensor it will incorrectly calibrate (will overflow) Then you will get spurious readings. This can be fixed by just recalibrating. Also it may be dust, too. Use a cotton swab to gently clean the sensor on the board. Let me know your answers and we should be able to get to a solution.

This is for a 3d printer.
I changed the board to 34 and hook it up like you show but i have no power at Aux2 for 5v, so i moved it to another location and i have lights.
My filament is black, when i calibrate i don't always get a reading of 1.55, as i write this it is stuck at 4.98 and this is after i calibrate it several times. I us the printer readout and a meter.

No worries i understand people work and have lives, I do.

If the output swings between 0 and 4.99 (or 5v) that means the calibration process was not right. When you press the calibration button, it takes a measurement of what ever is in there and then calibrates that to a 1.57v output. If it reads a 0 (or a low reading) for any reason it creates a very large calibration factor making the output swing between 0 and the maximum. This is because the factor = 1.57/0= infinity (or a large number) . Some reasons the calibration process could fail if: - the calibration rod is not flat against the sensor, There is light reflections in the case (no paint), there is dust or dirt on the sensor, the LED light is not uniform on the image sensor because it is blocked by something. One test you can do is do the calibration on the 3mm filament. Then you should see a reading of 1.57v or so when the 3mm filament is in there. If you try other filament slightly larger/smaller, the output will change from 1.57v. (eg 2.8mm yields 2.8/3.0*1.57v=1.46v) If this works, then we know the board works, but it is a calibration issue. Another test you can do is take the pc board out of the case and in a darkened room, lay the calibration rod on the sensor and hold the LED to shine down on the sensor and try to calibrate that way. You can then lay filament on the sensor and see if you get good readings that way. Then it might be an issue with the 3D printed case.

OK i finally had time to play with this, it turns out you were right the housing needed a little more filing and fine tuning. The unit works flawlessly now. Thank you for the support.

George

Thank you for clarifying this. Great work.

Top