Thanks for your continued support on this forum. This is a valuable resource.
I am trying to use the linescan sensor with a mobostamp-pe motherboard for deflection measurement of a thin backlit membrane. I wish to acquire a grayscale image at rate of 1k samples/sec. I believe this should be possible according to the TSL1401 datasheet. I have most of the optics figured out, however, I am new to programming in pbasic and having a difficult time ramping up. Specifically, I am having trouble outputing the analog pixel data to an available PWM output. If this is not advisable, I wish to import the raw pixel data into my pbasic program and saving it for later analysis as a csv file. I don't intend to capitalize the image processing abilities of the AVR and I understand that I can't becuase the analog data has to be exported out on the fly.
I hope to get started with a code snippet that I can integrate with the template provided on the parallax website. I am currently using the program listed on Pg 33 of the manual.
If there is any obvious flaw in my plan, please do not hesitate to point out. Thanks again for you support and help.
Your plan should work okay, except for the 1K 128-pixel frames/sec if you're using serial output. Just outputting the pixel data as raw 8-bit bytes would require a rate of 1000 * 128 * 11 = 1.4Mbaud -- far above what the BASIC Stamp can do.
Thanks Phil for the prompt reply.
I was afraid of that. Ok, I can use the Stamp to provide only the clock and SI signals. I understand this is an overkill, but boards like these are more expensive. I can feed the analog output from the parallax daughterboard into a high speed DAQ for post processing. The limitation is that the system cannot be synchronized, which is ok for now.
I was playing with this setup and was using the monitor program to control the linescan daughterboard. I can change the integration time but not the frame rate, which is only ~5Hz. Do you know, what's the clock frequency that's being used in the monitor program and how can I change it?
Instead of using the MoBo, you could use the Propeller Backpack. It has DUTY-mode DAC capabilities built-in, along with sigma-delta ADC for reading the TSL1401's output. (BTW, the TSL1401 board plugs into the Backpack, the same as with the MoBo.)
Thanks Phil. I will look into it.
I may be too much to ask, but do you have a sample program for the propeller with the daughterboard plugged-in to get me started.
Attached is a Backpack program that drives the TSL1401-DB plugged into it, writes the pixels to a 128-byte buffer, and scans the buffer, outputting a sync signal and a DUTY-mode DAC signal on the 2.5mm stereo phone jack. Here's a scope trace of what the outputs look like:
Since the DAC output is done in Spin, it's slower than, and asynchronous to, the sensor scan. Also, the driver program does not do continuous scanning; rather, it does a scan at the prescribed exposure time, then outputs the result of that scan.
Thank you so much Phil. This is very helpful. I appreciate your support.
I have yet to read and understand the backpack program. I have already ordered one. I hope it will be alright if I ask more questions.
These are some of my project photos, i have already said to you that in TSL1401_monitor_v1_4 i don't see clearly image as you, other problem is that i write your program post #14 but i didn't be able to upload your program in my MoBoStamp-pe, could you send me a video tutorial for doing that,
and i want how can you have obtained the image ikn the post #5, please help me. Thank you.
These are some of my project photos, i have already said to you that in TSL1401_monitor_v1_4 i don't see clearly image as you,
Several things come to mind:
1. The camera is oriented the wrong way. You want the linear array perpendicular to the direction of motion, not parallel to it, as you have.
2. The image is saturating. That means you have either too much light or too long an exposure time.
3. The lens looks like it's screwed in too far for the focal distance you've chosen.
4. To resolve the kind of detail apparent in the text on that sheet of paper, you will probably need to be much closer. Remember, the TSL1401 has only 128 pixels.
other problem is that i write your program post #14 but i didn't be able to upload your program in my MoBoStamp-pe
That program is loaded into the MoBoStampo-pe automatically when you start the monitor program. You don't need to load it explicitly.
Ok but the camera that you have used in post#5 is the same to TSL1401-DB o is a different type....... anyhoe the image captured with my cam isn't clear as your.....
1) Servo motor is neccessary.
2) To my cam i have uploded the firmware that i download from parallax website.
3)And i have used the LoadAVR.exe downloaded from parallax website, for upload to my moboset.
4) But the result is the same.
5)i followed all yours suggestions.
Again, you've got the camera oriented the wrong way. It needs to be a right angles to what you have now. Also, if you note my post #5, I have the camera mounted on a servo so that it can scan the subject. Finally, you're way too far from the subject to resolve any detail.
On my MoBoStamp-pe i have upload this code: ' ========================================================================='
' File...... tsl1401_template.bs2
' Purpose... Code template for the TSL1401-DB driver firmware.
' Author.... Parallax, Inc.
' E-mail.... support@parallax.com
' Started... 20 July 2007
' Updated...
'
' {$STAMP BS2pe}
' {$PBASIC 2.5}
'
' =========================================================================
'
[ Program Description ]
' This is a blank template used for interacting with the TSL1401 driver
' firmware in the MoBoStamp-pe's AVR coprocessor.
'
[ I/O Definitions ]
owio PIN 6 'Pin for OWIN and OWOUT to AVR coprocessor.
'
[ Constants ]
' Commands
SETLED CON $EB 'Set LED strobe and brightness/time from next byte.
'Flag to OR to brightness/time (0 - 127) value.
TIME CON $80 'Set strobe: value (0 - 127) is 0 - 3.4mS at 100% on.
INTEN CON $00 'Set intensity: value (0 - 127) is 0 - 49.6% on.
SETBIN CON $EC 'Set threshold, hysteresis, and filter (3 bytes).
'Filter flags.
FLOAT CON $80 'Threshold is floating per filter value (0 - 7).
FIXED CON $00 'Threshold is fixed.
WINDOW CON $40 'Threshold is a window (outside of hysteresis band).
LEVEL CON $00 'Threshold is a level with hysteresis.
SETEXP CON $EE 'Set exposure to byte (1 - 255) following: 0.27 - 68mS.
ACQGRAY CON $A0 'Acquire and dump a grayscale image.
ACQBIN CON $A4 'Acquire a binary image.
ACQAND CON $A1 'Acquire binary image ANDed w/ previous.
ACQOR CON $A2 'Acquire binary image ORed w/ previous.
ACQXOR CON $A3 'Acquire binary image XORed w/ previous.
ACQANDNOT CON $A5 'Acquire binary image ANDed w/ NOT prev.
ACQORNOT CON $A6 'Acquire binary image ORed w/ NOT prev.
ACQXORNOT CON $A7 'Acquire binary image XORed w/ NOT prev.
ACQDIFF CON $A3 'Idiom for ACQXOR.
ACQSAME CON $A7 'Idiom for ACQXORNOT.
XTRIG CON $08 'External trigger flag, ORed to ACQ commands.
CNTNEW CON $C8 'Count pixels/edges between new bounds.
CNTNXT CON $C0 'Count pixels/edges between current bounds.
FNDNEW CON $F8 'Find first pixel/edge between new bounds.
FNDNXT CON $F0 'Find first pixel/edge between current bounds.
'Modifiers, ORed to CNTNEW, CNTNXT, FNDNEW, and FNDNXT.
NXT CON $00 'Continue from where last CNT or FND left off.
BKWD CON $04 'Search backward.
FWD CON $00 'Search forward.
DRKPIX CON $00 'Target is a dark pixel.
BRTPIX CON $02 'Target is a bright pixel.
DRKEDG CON $03 'Target is a bright-to-dark edge.
BRTEDG CON $01 'Target is a dark-to-bright edge.
DUMPADR CON $DA 'Dump data, beginning at addr, and until reset.
'Address constants for single byte arg following DUMPADR.
PIXELS CON $00 'Beginning of binary pixel buffer (32 bytes).
RESULTS CON $20 'Beginning of results buffer.
MINPIX CON $20 'Value of darkest pixel (0 - 255).
MINLOC CON $21 'Location of darkest pixel (0 - 127).
MAXPIX CON $22 'Value of brightest pixel (0 - 255).
MAXLOC CON $23 'Location of brightest pixel (0 - 127).
AVGPIX CON $24 'Average pixel value (0 - 255).
DUMPID CON $DD 'Dump the firmware ID (returns 3 bytes).
DUMPFLAGS CON $DF 'Dump error flags (returns 1 byte).
'Bit positions in returned byte.
BADCMD CON $80 'Unrecognized command.
CANTBUF CON $40 'Attempt to buffer unbufferable command.
CMDOVF CON $20 'Command buffer overflow.
DATOVF CON $10 'Result data buffer overflow.
'
[ Variables ]
flags VAR Byte
busy VAR Bit
'
[ Initialization ]
PAUSE 10 'Wait for AVR to finish reset.
'
[ Program Code ]
' Your program code goes here.
END
'
[ Subroutines ]
'
[ Ready ]
' Wait for the driver to become not busy.
Ready:
DO
OWIN owio, 4, [busy] 'Read busy bit.
LOOP WHILE busy 'Keep checking until it goes low.
RETURN
'
[ GetError ]
' Read the error flags from the driver.
GetError:
OWOUT owio, 0, [DUMPFLAGS] 'Read the error flags.
OWIN owio, 0, [flags]
IF (flags = $FF) THEN 'If $FF, driver is waiting for a reset.
OWOUT owio, 1, [DUMPFLAGS] 'So reset and try again.
OWIN owio, 0, [flags]
ENDIF
RETURN
Okay Phil,
I nedd to capture a good image, then i have to write a program code, right?
Your code is that you have used in post #14, right?
Now i haven't got a servo to move my TSL1401-DB, and i want to konw if without a servo, the experiment be successful......
The code in post #14 is what gets loaded to the MoBo when you start the monitor program. It may or may not be what you need for your app. (What is your app, BTW?)
Without a servo or some other means to physcially scan either the camera or the subject, you will not obtain a full image, but just a one-line slice.
I am trying using TSL1401-DB linescan camera module for object detection. I wish to acquire a grayscale image for the 1K 128-pixel frames/sec.
Do you know, how can you solve that problem?
Thank you so much for support and help.
To achieve 1000 fps, you will need a clock speed of at least 128 kHz and an A/D converter that can sample and convert at that speed. I recommend a parallel-output converter to achieve that speed. Otherwise, with a serial-output converter, you would need a serial clock of more than 1 MHz.
The other thing you will need is plenty of light, since your integration times will be 1 ms. or less.
Good luck with your project! Can you divulge what it is you're looking at?
Thank you very much for the prompt reply.
I am a student, I am researching a project for my professor. He proposed to use TSL1401-DB linescan camera module and achieve 1000 frame/sec. I am studying your proposed information but I don't know what to start or what device to use to achieve that speed. I hope you can give more specific guidance or suggest the necessary device to do.
Look forward to receiving your help and thank you very much.
Currently, I am using Arduino Uno board but it did not achieve the same results at first. I am trying to find other microcontrollers to use to obtain and transmit the data.
Currently, I am using Arduino Uno board but it did not achieve the same results at first. I am trying to find other microcontrollers to use to obtain and transmit the data.
Joseph Pham
Since this is a Parallax forum and they make the Propeller chip I would suggest using one of the Propeller boards. On top of being fast enough you will also benefit from having sample code from the OBEX and help from some very smart and experienced people on this forum.
Comments
Thanks for your continued support on this forum. This is a valuable resource.
I am trying to use the linescan sensor with a mobostamp-pe motherboard for deflection measurement of a thin backlit membrane. I wish to acquire a grayscale image at rate of 1k samples/sec. I believe this should be possible according to the TSL1401 datasheet. I have most of the optics figured out, however, I am new to programming in pbasic and having a difficult time ramping up. Specifically, I am having trouble outputing the analog pixel data to an available PWM output. If this is not advisable, I wish to import the raw pixel data into my pbasic program and saving it for later analysis as a csv file. I don't intend to capitalize the image processing abilities of the AVR and I understand that I can't becuase the analog data has to be exported out on the fly.
I hope to get started with a code snippet that I can integrate with the template provided on the parallax website. I am currently using the program listed on Pg 33 of the manual.
If there is any obvious flaw in my plan, please do not hesitate to point out. Thanks again for you support and help.
Rahil
Your plan should work okay, except for the 1K 128-pixel frames/sec if you're using serial output. Just outputting the pixel data as raw 8-bit bytes would require a rate of 1000 * 128 * 11 = 1.4Mbaud -- far above what the BASIC Stamp can do.
-Phil
I was afraid of that. Ok, I can use the Stamp to provide only the clock and SI signals. I understand this is an overkill, but boards like these are more expensive. I can feed the analog output from the parallax daughterboard into a high speed DAQ for post processing. The limitation is that the system cannot be synchronized, which is ok for now.
I was playing with this setup and was using the monitor program to control the linescan daughterboard. I can change the integration time but not the frame rate, which is only ~5Hz. Do you know, what's the clock frequency that's being used in the monitor program and how can I change it?
Instead of using the MoBo, you could use the Propeller Backpack. It has DUTY-mode DAC capabilities built-in, along with sigma-delta ADC for reading the TSL1401's output. (BTW, the TSL1401 board plugs into the Backpack, the same as with the MoBo.)
-Phil
I may be too much to ask, but do you have a sample program for the propeller with the daughterboard plugged-in to get me started.
Attached is a Backpack program that drives the TSL1401-DB plugged into it, writes the pixels to a 128-byte buffer, and scans the buffer, outputting a sync signal and a DUTY-mode DAC signal on the 2.5mm stereo phone jack. Here's a scope trace of what the outputs look like:
Since the DAC output is done in Spin, it's slower than, and asynchronous to, the sensor scan. Also, the driver program does not do continuous scanning; rather, it does a scan at the prescribed exposure time, then outputs the result of that scan.
-Phil
I have yet to read and understand the backpack program. I have already ordered one. I hope it will be alright if I ask more questions.
-Phil
These are some of my project photos, i have already said to you that in TSL1401_monitor_v1_4 i don't see clearly image as you, other problem is that i write your program post #14 but i didn't be able to upload your program in my MoBoStamp-pe, could you send me a video tutorial for doing that,
and i want how can you have obtained the image ikn the post #5, please help me. Thank you.
-Harjit......
2. The image is saturating. That means you have either too much light or too long an exposure time.
3. The lens looks like it's screwed in too far for the focal distance you've chosen.
4. To resolve the kind of detail apparent in the text on that sheet of paper, you will probably need to be much closer. Remember, the TSL1401 has only 128 pixels.
-Phil
Ok but the camera that you have used in post#5 is the same to TSL1401-DB o is a different type....... anyhoe the image captured with my cam isn't clear as your.....
1) Servo motor is neccessary.
2) To my cam i have uploded the firmware that i download from parallax website.
3)And i have used the LoadAVR.exe downloaded from parallax website, for upload to my moboset.
4) But the result is the same.
5)i followed all yours suggestions.
-Phil
-Phil
Now i have oriented in right way.....
and which function has the center yellow line in the post #5 that you see with the TSLI1401-DB MONITOR.....
-Phil
' ========================================================================='
' File...... tsl1401_template.bs2
' Purpose... Code template for the TSL1401-DB driver firmware.
' Author.... Parallax, Inc.
' E-mail.... support@parallax.com
' Started... 20 July 2007
' Updated...
'
' {$STAMP BS2pe}
' {$PBASIC 2.5}
'
' =========================================================================
'
[ Program Description ]
' This is a blank template used for interacting with the TSL1401 driver
' firmware in the MoBoStamp-pe's AVR coprocessor.
'
[ I/O Definitions ]
owio PIN 6 'Pin for OWIN and OWOUT to AVR coprocessor.
'
[ Constants ]
' Commands
SETLED CON $EB 'Set LED strobe and brightness/time from next byte.
'Flag to OR to brightness/time (0 - 127) value.
TIME CON $80 'Set strobe: value (0 - 127) is 0 - 3.4mS at 100% on.
INTEN CON $00 'Set intensity: value (0 - 127) is 0 - 49.6% on.
SETBIN CON $EC 'Set threshold, hysteresis, and filter (3 bytes).
'Filter flags.
FLOAT CON $80 'Threshold is floating per filter value (0 - 7).
FIXED CON $00 'Threshold is fixed.
WINDOW CON $40 'Threshold is a window (outside of hysteresis band).
LEVEL CON $00 'Threshold is a level with hysteresis.
SETEXP CON $EE 'Set exposure to byte (1 - 255) following: 0.27 - 68mS.
ACQGRAY CON $A0 'Acquire and dump a grayscale image.
ACQBIN CON $A4 'Acquire a binary image.
ACQAND CON $A1 'Acquire binary image ANDed w/ previous.
ACQOR CON $A2 'Acquire binary image ORed w/ previous.
ACQXOR CON $A3 'Acquire binary image XORed w/ previous.
ACQANDNOT CON $A5 'Acquire binary image ANDed w/ NOT prev.
ACQORNOT CON $A6 'Acquire binary image ORed w/ NOT prev.
ACQXORNOT CON $A7 'Acquire binary image XORed w/ NOT prev.
ACQDIFF CON $A3 'Idiom for ACQXOR.
ACQSAME CON $A7 'Idiom for ACQXORNOT.
XTRIG CON $08 'External trigger flag, ORed to ACQ commands.
CNTNEW CON $C8 'Count pixels/edges between new bounds.
CNTNXT CON $C0 'Count pixels/edges between current bounds.
FNDNEW CON $F8 'Find first pixel/edge between new bounds.
FNDNXT CON $F0 'Find first pixel/edge between current bounds.
'Modifiers, ORed to CNTNEW, CNTNXT, FNDNEW, and FNDNXT.
NXT CON $00 'Continue from where last CNT or FND left off.
BKWD CON $04 'Search backward.
FWD CON $00 'Search forward.
DRKPIX CON $00 'Target is a dark pixel.
BRTPIX CON $02 'Target is a bright pixel.
DRKEDG CON $03 'Target is a bright-to-dark edge.
BRTEDG CON $01 'Target is a dark-to-bright edge.
DUMPADR CON $DA 'Dump data, beginning at addr, and until reset.
'Address constants for single byte arg following DUMPADR.
PIXELS CON $00 'Beginning of binary pixel buffer (32 bytes).
RESULTS CON $20 'Beginning of results buffer.
MINPIX CON $20 'Value of darkest pixel (0 - 255).
MINLOC CON $21 'Location of darkest pixel (0 - 127).
MAXPIX CON $22 'Value of brightest pixel (0 - 255).
MAXLOC CON $23 'Location of brightest pixel (0 - 127).
AVGPIX CON $24 'Average pixel value (0 - 255).
DUMPID CON $DD 'Dump the firmware ID (returns 3 bytes).
DUMPFLAGS CON $DF 'Dump error flags (returns 1 byte).
'Bit positions in returned byte.
BADCMD CON $80 'Unrecognized command.
CANTBUF CON $40 'Attempt to buffer unbufferable command.
CMDOVF CON $20 'Command buffer overflow.
DATOVF CON $10 'Result data buffer overflow.
'
[ Variables ]
flags VAR Byte
busy VAR Bit
'
[ Initialization ]
PAUSE 10 'Wait for AVR to finish reset.
'
[ Program Code ]
' Your program code goes here.
END
'
[ Subroutines ]
'
[ Ready ]
' Wait for the driver to become not busy.
Ready:
DO
OWIN owio, 4, [busy] 'Read busy bit.
LOOP WHILE busy 'Keep checking until it goes low.
RETURN
'
[ GetError ]
' Read the error flags from the driver.
GetError:
OWOUT owio, 0, [DUMPFLAGS] 'Read the error flags.
OWIN owio, 0, [flags]
IF (flags = $FF) THEN 'If $FF, driver is waiting for a reset.
OWOUT owio, 1, [DUMPFLAGS] 'So reset and try again.
OWIN owio, 0, [flags]
ENDIF
RETURN
For the program to do anything, you have to add your own PBASIC code.
But before you do anything else, you really need to get a good image in the monitor, so you know what settings to use in your app.
-Phil
I nedd to capture a good image, then i have to write a program code, right?
Your code is that you have used in post #14, right?
Now i haven't got a servo to move my TSL1401-DB, and i want to konw if without a servo, the experiment be successful......
Without a servo or some other means to physcially scan either the camera or the subject, you will not obtain a full image, but just a one-line slice.
-Phil
-HARJIT
-Phil
I am trying using TSL1401-DB linescan camera module for object detection. I wish to acquire a grayscale image for the 1K 128-pixel frames/sec.
Do you know, how can you solve that problem?
Thank you so much for support and help.
Joseph Pham
Welcome to the forum!
To achieve 1000 fps, you will need a clock speed of at least 128 kHz and an A/D converter that can sample and convert at that speed. I recommend a parallel-output converter to achieve that speed. Otherwise, with a serial-output converter, you would need a serial clock of more than 1 MHz.
The other thing you will need is plenty of light, since your integration times will be 1 ms. or less.
Good luck with your project! Can you divulge what it is you're looking at?
-Phil
Thank you very much for the prompt reply.
I am a student, I am researching a project for my professor. He proposed to use TSL1401-DB linescan camera module and achieve 1000 frame/sec. I am studying your proposed information but I don't know what to start or what device to use to achieve that speed. I hope you can give more specific guidance or suggest the necessary device to do.
Look forward to receiving your help and thank you very much.
Joseph Pham
Which microcontroller are you using to obtain and transmit the data?
-Phil
Currently, I am using Arduino Uno board but it did not achieve the same results at first. I am trying to find other microcontrollers to use to obtain and transmit the data.
Joseph Pham
Since this is a Parallax forum and they make the Propeller chip I would suggest using one of the Propeller boards. On top of being fast enough you will also benefit from having sample code from the OBEX and help from some very smart and experienced people on this forum.
https://www.digikey.com/product-detail/en/analog-devices-inc/AD7819YNZ/AD7819YNZ-ND/997013
It's spec'd to 200 ksps and has a parallel 8-bit output.
-Phil