Barcode reader with a TCD1304AP TOSHIBA CCD linear image sensor and NUCLEO-F103RB board.

Dependencies:   mbed zbar

Barcode Reader

Barcodes represent data by varying the widths of spaces and bars. These barcodes, now commonly referred to as linear or one-dimensional (1D), can be scanned by barcode readers. In this project a TCD1304AP TOSHIBA CCD linear image sensor is used to scan barcodes. The obtained light intensity stream is passed to the ZBar library streamlined for embedded use.

Flow charthttps://os.mbed.com/media/uploads/hudakz/barcodereader_diagram.png
TCD1304AP Driver

The TCD1304AP requires three clock signals (see below the Timing chart). It can operate with or without a built-in electronic shutter. In this project the electronic shutter is used to control the integration (exposure) time:

https://os.mbed.com/media/uploads/hudakz/barcodereader_timing.png




I used STM32CubeIDE to build the driver for the TCD1304AP sensor and then merged it with the Mbed OS 2 project.

STM32F103RB clock configuration
https://os.mbed.com/media/uploads/hudakz/barcodereader_clockconf.png


STM32F103RB pinout
https://os.mbed.com/media/uploads/hudakz/barcodereader_pinout.png


  • The signal for TCD1304AP's master clock (fiM) is generated by STM32F103's TIM1 timer and it is output at pin PA_8.
  • The Shift Gate clock signal (SH) is produced by timer TIM2 and it's available at pin PA_15.
  • The Integration Clear Gate pulses (ICG) are generated by timer TIM3 at pin PA_6.

The TCD1304AP's master clock runs at 1.714MHz. Pixel data is available at its output (OS) after each four pulses. To keep up with such speed DMA (Direct Memmory Access) is used to move the voltage data produced by the ADC (Analog to Digital Convertor) into the STM32F103's SRAM. The ADC is clocked with a 12MHz signal and runs in continuous mode.

https://os.mbed.com/media/uploads/hudakz/barcodereader_clocking.png

Committer:
hudakz
Date:
Fri Jan 10 22:10:07 2020 +0000
Revision:
3:f2e67488f5ab
Parent:
0:cd0771c3346e
Barcode reader with a TCD1304AP TOSHIBA CCD linear image sensor and NUCLEO-F103RB board.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hudakz 0:cd0771c3346e 1 /* USER CODE BEGIN Header */
hudakz 0:cd0771c3346e 2 /**
hudakz 0:cd0771c3346e 3 ******************************************************************************
hudakz 0:cd0771c3346e 4 * @file stm32f1xx_it.h
hudakz 0:cd0771c3346e 5 * @brief This file contains the headers of the interrupt handlers.
hudakz 0:cd0771c3346e 6 ******************************************************************************
hudakz 0:cd0771c3346e 7 * @attention
hudakz 0:cd0771c3346e 8 *
hudakz 0:cd0771c3346e 9 * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
hudakz 0:cd0771c3346e 10 * All rights reserved.</center></h2>
hudakz 0:cd0771c3346e 11 *
hudakz 0:cd0771c3346e 12 * This software component is licensed by ST under BSD 3-Clause license,
hudakz 0:cd0771c3346e 13 * the "License"; You may not use this file except in compliance with the
hudakz 0:cd0771c3346e 14 * License. You may obtain a copy of the License at:
hudakz 0:cd0771c3346e 15 * opensource.org/licenses/BSD-3-Clause
hudakz 0:cd0771c3346e 16 *
hudakz 0:cd0771c3346e 17 ******************************************************************************
hudakz 0:cd0771c3346e 18 */
hudakz 0:cd0771c3346e 19 /* USER CODE END Header */
hudakz 0:cd0771c3346e 20
hudakz 0:cd0771c3346e 21 /* Define to prevent recursive inclusion -------------------------------------*/
hudakz 0:cd0771c3346e 22 #ifndef __STM32F1xx_IT_H
hudakz 0:cd0771c3346e 23 #define __STM32F1xx_IT_H
hudakz 0:cd0771c3346e 24
hudakz 0:cd0771c3346e 25 #ifdef __cplusplus
hudakz 0:cd0771c3346e 26 extern "C" {
hudakz 0:cd0771c3346e 27 #endif
hudakz 0:cd0771c3346e 28
hudakz 0:cd0771c3346e 29 /* Private includes ----------------------------------------------------------*/
hudakz 0:cd0771c3346e 30 /* USER CODE BEGIN Includes */
hudakz 0:cd0771c3346e 31
hudakz 0:cd0771c3346e 32 /* USER CODE END Includes */
hudakz 0:cd0771c3346e 33
hudakz 0:cd0771c3346e 34 /* Exported types ------------------------------------------------------------*/
hudakz 0:cd0771c3346e 35 /* USER CODE BEGIN ET */
hudakz 0:cd0771c3346e 36
hudakz 0:cd0771c3346e 37 /* USER CODE END ET */
hudakz 0:cd0771c3346e 38
hudakz 0:cd0771c3346e 39 /* Exported constants --------------------------------------------------------*/
hudakz 0:cd0771c3346e 40 /* USER CODE BEGIN EC */
hudakz 0:cd0771c3346e 41
hudakz 0:cd0771c3346e 42 /* USER CODE END EC */
hudakz 0:cd0771c3346e 43
hudakz 0:cd0771c3346e 44 /* Exported macro ------------------------------------------------------------*/
hudakz 0:cd0771c3346e 45 /* USER CODE BEGIN EM */
hudakz 0:cd0771c3346e 46
hudakz 0:cd0771c3346e 47 /* USER CODE END EM */
hudakz 0:cd0771c3346e 48
hudakz 0:cd0771c3346e 49 /* Exported functions prototypes ---------------------------------------------*/
hudakz 0:cd0771c3346e 50 void NMI_Handler(void);
hudakz 0:cd0771c3346e 51 void HardFault_Handler(void);
hudakz 0:cd0771c3346e 52 void MemManage_Handler(void);
hudakz 0:cd0771c3346e 53 void BusFault_Handler(void);
hudakz 0:cd0771c3346e 54 void UsageFault_Handler(void);
hudakz 0:cd0771c3346e 55 void SVC_Handler(void);
hudakz 0:cd0771c3346e 56 void DebugMon_Handler(void);
hudakz 0:cd0771c3346e 57 void PendSV_Handler(void);
hudakz 0:cd0771c3346e 58 void SysTick_Handler(void);
hudakz 0:cd0771c3346e 59 void DMA1_Channel1_IRQHandler(void);
hudakz 0:cd0771c3346e 60 void TIM1_UP_IRQHandler(void);
hudakz 0:cd0771c3346e 61 void TIM3_IRQHandler(void);
hudakz 0:cd0771c3346e 62 /* USER CODE BEGIN EFP */
hudakz 0:cd0771c3346e 63
hudakz 0:cd0771c3346e 64 /* USER CODE END EFP */
hudakz 0:cd0771c3346e 65
hudakz 0:cd0771c3346e 66 #ifdef __cplusplus
hudakz 0:cd0771c3346e 67 }
hudakz 0:cd0771c3346e 68 #endif
hudakz 0:cd0771c3346e 69
hudakz 0:cd0771c3346e 70 #endif /* __STM32F1xx_IT_H */
hudakz 0:cd0771c3346e 71
hudakz 0:cd0771c3346e 72 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
hudakz 0:cd0771c3346e 73