Skip to main content

How to use ADC PWM I2C library in VCSharp

danger

this is a legacy library and thus not supported by Toradex anymore. We recommend that you use the new libraries for all Toradex modules. Please see the Toradex CE Libraries and Code Samples for up-to-date information.


This article aims to help the developer, to use Toradex libraries (ADC, PWM and I2C) in Visual C#.

How to use ADC Library in VCSharp

ADC library gives easy access to 4 channels of Analog to Digital converter available on Toradex module.

Use cases are:

  • Temperature sensor
  • Light sensor
  • Accelerometer
  • and many more..

ADC hardware setup

Connect Analog signals to the analog input pins (SODIMM pin 2, 4, 6 and 8) on X14 header of Colibri Evaluation Board V3.1A.

ADC demo application

This application demonstrates how to read analog input using ADC.

  • Download ADC demo source code from here.
  • Download and Install .NET Compact Framework on device from here.
  • Navigate to Solution Explorer in visual studio, Right Click on vcsharp_adc_demo > Properties > Devices.
  • Uncheck Deploy the Latest version of the .NET Compact Framework (including Service Packs).
  • Navigate to Solution Explorer in visual studio, Right Click on vcsharp_adc_demo > Properties > Build.
  • Check Allow unsafe code.
  • Build and Deploy solution.
  • On the Toradex Module go to My Device > Program Files > vcsharp_adc_demo. Double click on the vcsharp_adc_demo.exe to run the application.

Analog values measured from ADC channels are displayed on respective text boxes and vertical slider controls.

How to use PWM Library in VCSharp

PWM library gives easy access to 4 channel of PWM available on Toradex module.

Use cases are:

  • LCD back-light control
  • Servo motor control
  • and many more..

Refer this article for more information about PWM channels available on Colibri modules.

PWM hardware setup

Connect PWM Channels (SODIMM Pins 59, 28, 30 and 67) on Colibri Evaluation Board V3.1A to Oscilloscope.

NOTE - For PXA3xx PWM channel 1 is available at SODIMM pin 152, refer PWM reference table from this article.

PWM demo application

This application demonstrates how to produce PWM signal at different PWM Channels.

  • Download PWM demo source code from here.
  • Download and Install .NET Compact Framework on device from here.
  • Navigate to Solution Explorer in visual studio, Right Click on vcsharp_pwm_demo > Properties > Devices.
  • Uncheck Deploy the Latest version of the .NET Compact Framework (including Service Packs).
  • Build and deploy solution.
  • On the Toradex Module go to My Device > Program Files > vcsharp_pwm_demo. Double click on the vcsharp_pwm_demo.exe to run the application.
  • Select the frequency and duty-cycle for different channels and click on Set Button.

All channels are set at frequency of 50Hz on Colibri T20 with different duty- cycle as shown in the picture below.

All channels are set at duty-cycle of 50% on Colibri T20 with different Frequency as shown in the picture below.

How to use I2C Library in VCSharp

I2C Library provides easy access to I2C interface available on Toradex modules.

Some of the devices that can be interfaced using I2C library are:

  • EEPROM
  • Real Time Clock
  • I/O expander
  • Touch screen LCD
  • Audio codec
  • and many more..

I2C hardware setup

In this demo EEPROM 24C256 has been interfaced with Colibri Evaluation Board V3.1A. Connect SDA and SCL pin of EEPROM chip to I2C_SDA (SODIMM pin 194) and I2C_SCL (SODIMM pin 196) respectively available on X9 connector of Colibri Evaluation Board V3.1A.

I2C demo application

This application demonstrates how to use Toradex I2C library to read time, day of the week, date from the Real Time Clock (RTC) and to perform read & write operation on EEPROM chip.

  • Download I2C demo source code from here.
  • Download and Install .NET Compact Framework on device from here.
  • Navigate to Solution Explorer in visual studio, Right Click on vcsharp_i2c_demo > Properties > Devices.
  • Uncheck Deploy the Latest version of the .NET Compact Framework(including Service Packs).
  • Navigate to Solution Explorer in visual studio, Right Click on vcsharp_i2c_demo > Properties > Build.
  • Check Allow unsafe code.
  • Build and deploy solution.
  • On the Colibri Module go to My Device > Program Files > vcsharp_i2c_demo. Double click on the vcsharp_i2c_demo.exe to run the application.

Follow the steps as mentioned below:

  • Select the device as RTC or EEPROM.
  • Set the address of selected device eg: set 104 as the address if RTC is selected and set 80 as the address if EEPROM is selected.
  • Set the operation (Read/Write) to be performed.
  • Click on the button (Read/Write) to perform read or write operation.

Reading time, date and day from RTC.

Writing Data on EEPROM.

Reading Data from EEPROM.



Send Feedback!