Simple test application for X-NUCLEO-IKA01A1 expansion board.
Dependencies: X_NUCLEO_IKA01A1 mbed
Fork of HelloWorld_IKA01A1 by
Simple test application for X-NUCLEO-IKA01A1 expansion board.
Platform compatibility issues
- NUCLEO-F302R8: use pin D5 for LED Driver configuration
- LPCXpresso11U68: use pin D3 as PWM for LED Driver configuration. Use a free Dx pin as Signal2 for Windows Comparator configuration.
Diff: main.cpp
- Revision:
- 21:3b3d7bfcf94b
- Parent:
- 20:7f25e4cedd1a
diff -r 7f25e4cedd1a -r 3b3d7bfcf94b main.cpp
--- a/main.cpp Thu Jul 13 15:46:19 2017 +0000
+++ b/main.cpp Wed Oct 18 17:00:11 2017 +0000
@@ -49,51 +49,52 @@
/* Variables -----------------------------------------------------------------*/
Serial pc(USBTX, USBRX);
-//Serial pc(SERIAL_TX, SERIAL_RX);
DigitalOut myled(LED1);
/* Functions -----------------------------------------------------------------*/
int main() {
- XNucleoIKA01A1 *analog_expansion_board = XNucleoIKA01A1::instance(X_NUCLEO_IKA01A1_PIN_INSTRUMENTATION_AMP,
- X_NUCLEO_IKA01A1_PIN_CURRENT_SENSING,
- X_NUCLEO_IKA01A1_PIN_PHOTO_SENSOR,
- X_NUCLEO_IKA01A1_PIN_WINDOWS_COMP_SIGNAL_1,
- X_NUCLEO_IKA01A1_PIN_WINDOWS_COMP_SIGNAL_2,
- X_NUCLEO_IKA01A1_PIN_PWM_LED_DRIVER_OUTPUT,
- 5000);
+ XNucleoIKA01A1 *analog_expansion_board = XNucleoIKA01A1::instance(
+ X_NUCLEO_IKA01A1_PIN_INSTRUMENTATION_AMP,
+ X_NUCLEO_IKA01A1_PIN_CURRENT_SENSING,
+ X_NUCLEO_IKA01A1_PIN_PHOTO_SENSOR,
+ X_NUCLEO_IKA01A1_PIN_WINDOWS_COMP_SIGNAL_1,
+ X_NUCLEO_IKA01A1_PIN_WINDOWS_COMP_SIGNAL_2,
+ X_NUCLEO_IKA01A1_PIN_PWM_LED_DRIVER_OUTPUT,
+ 5000
+ );
+
analog_expansion_board->init();
TSZ124 *instr_amp = analog_expansion_board->tsz124;
TSU104 *photo_sensor_wind_comp = analog_expansion_board->tsu104;
- TSV734 *led_driver = analog_expansion_board->tsv734;
- double duty_cycle = 0;
-
- while(1) {
- pc.printf("\nLooping...\n");
+ TSV734 *led_driver = analog_expansion_board->tsv734;
+ double duty_cycle = 0;
+ /* Printing to the console. */
+ pc.printf("Analog Application Example\r\n\n");
+
+ /* Looping. */
+ while(1) {
unsigned int op_amp_voltage = instr_amp->get_voltage();
unsigned int op_amp_current = instr_amp->get_current();
- // pass the analog pin name on which voltage is to be read (e.g. A3 on LPCxpresso lpc11u68)
- unsigned int photo_sensor_voltage = photo_sensor_wind_comp->get_voltage();
- unsigned int wind_com_pin1 = photo_sensor_wind_comp->get_signal1();
- unsigned int wind_com_pin2 = photo_sensor_wind_comp->get_signal2();
-
- pc.printf("\nopAmp measured voltage(mV): %u \n", op_amp_voltage);
- pc.printf("\nopAmp measured Current(mA): %u \n", op_amp_current);
- pc.printf("\nphotodiode sensor output voltage(mV): %u \n", photo_sensor_voltage);
- pc.printf("\nWindows comparator: signal 1 value(pin D2): %u \n", wind_com_pin1);
- pc.printf("\nWindows comparator: signal 1 value(pin D4): %u \n", wind_com_pin2);
+ unsigned int photo_sensor_voltage = photo_sensor_wind_comp->get_voltage();
+ unsigned int wind_com_pin1 = photo_sensor_wind_comp->get_signal1();
+ unsigned int wind_com_pin2 = photo_sensor_wind_comp->get_signal2();
- duty_cycle += 0.1;
+ pc.printf("\r\nOpAmp measured Voltage(mV): %u", op_amp_voltage);
+ pc.printf("\r\nOpAmp measured Current(mA): %u", op_amp_current);
+ pc.printf("\r\nPhotodiode sensor output voltage(mV): %u", photo_sensor_voltage);
+ pc.printf("\r\nWindows comparator: signal 1 value(pin D2): %u", wind_com_pin1);
+ pc.printf("\r\nWindows comparator: signal 1 value(pin D4): %u", wind_com_pin2);
+ pc.printf("\r\nLED Driver: duty cycle: %.2lf %%\r\n", led_driver->set_duty_cycle(duty_cycle));
+
+ duty_cycle += 0.1;
if (duty_cycle >= 1) {
duty_cycle = 0;
}
-
- pc.printf("\nLED Driver: duty cycle: %.2lf percent \n", led_driver->set_duty_cycle(duty_cycle));
-
+
myled = !myled;
wait(1);
}
}
-

X-NUCLEO-IKA01A1 Multifunctional board based on operational amplifiers.