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.
main.cpp@16:2159a3dc888e, 2016-04-13 (annotated)
- Committer:
- hemddabral
- Date:
- Wed Apr 13 06:22:38 2016 +0000
- Revision:
- 16:2159a3dc888e
- Parent:
- 15:edec8fd4f69c
- Child:
- 19:a8d8f1ef04f6
updated X-Nucleo-IKA01A1 library and main.cpp
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hemddabral | 0:0f16e14940d0 | 1 | #include "mbed.h" |
hemddabral | 2:af24b3afa99d | 2 | #include "x_nucleo_ika01a1_class.h" |
hemddabral | 0:0f16e14940d0 | 3 | |
hemddabral | 3:5c45cb513aaf | 4 | Serial pc(USBTX, USBRX); |
hemddabral | 0:0f16e14940d0 | 5 | |
hemddabral | 14:182526e41810 | 6 | //Serial pc(SERIAL_TX, SERIAL_RX); |
hemddabral | 14:182526e41810 | 7 | |
hemddabral | 0:0f16e14940d0 | 8 | DigitalOut myled(LED1); |
hemddabral | 0:0f16e14940d0 | 9 | |
hemddabral | 4:6ed99ea3bf33 | 10 | int main() { |
hemddabral | 16:2159a3dc888e | 11 | X_NUCLEO_IKA01A1 *analog_expansion_board = X_NUCLEO_IKA01A1::Instance(X_NUCLEO_IKA01A1_PIN_INSTRUMENTATION_AMP, |
hemddabral | 16:2159a3dc888e | 12 | X_NUCLEO_IKA01A1_PIN_CURRENT_SENSING, |
hemddabral | 16:2159a3dc888e | 13 | X_NUCLEO_IKA01A1_PIN_PHOTO_SENSOR, |
hemddabral | 11:71be8ec1ce5c | 14 | X_NUCLEO_IKA01A1_PIN_WINDOWS_COMP_SIGNAL_1, |
hemddabral | 11:71be8ec1ce5c | 15 | X_NUCLEO_IKA01A1_PIN_WINDOWS_COMP_SIGNAL_2, |
hemddabral | 11:71be8ec1ce5c | 16 | X_NUCLEO_IKA01A1_PIN_PWM_LED_DRIVER_OUTPUT, |
hemddabral | 15:edec8fd4f69c | 17 | 5000); |
hemddabral | 2:af24b3afa99d | 18 | analog_expansion_board->Init(); |
hemddabral | 2:af24b3afa99d | 19 | TSZ124 *instrAmp = analog_expansion_board->tsz124; |
hemddabral | 4:6ed99ea3bf33 | 20 | TSU104 *photoSensor_windComp = analog_expansion_board->tsu104; |
hemddabral | 2:af24b3afa99d | 21 | |
hemddabral | 9:9b48d36016c3 | 22 | TSV734 *led_Driver = analog_expansion_board->tsv734; |
hemddabral | 13:179d5044bbc1 | 23 | double dutyCycle = 0; |
hemddabral | 9:9b48d36016c3 | 24 | |
hemddabral | 4:6ed99ea3bf33 | 25 | while(1) { |
hemddabral | 3:5c45cb513aaf | 26 | pc.printf("\nwhile loop\n"); |
hemddabral | 3:5c45cb513aaf | 27 | |
hemddabral | 4:6ed99ea3bf33 | 28 | unsigned int opAmpVoltage = instrAmp->GetVoltage(); |
hemddabral | 4:6ed99ea3bf33 | 29 | unsigned int opAmpCurrent = instrAmp->GetCurrent(); |
hemddabral | 7:41935875cb26 | 30 | // pass the analog pin name on which voltage is to be read (e.g. A3 on LPCxpresso lpc11u68) |
hemddabral | 16:2159a3dc888e | 31 | unsigned int photoSensorVoltage = photoSensor_windComp->GetVoltage(); |
hemddabral | 16:2159a3dc888e | 32 | unsigned int windComPin1 = photoSensor_windComp->GetSignal1(); |
hemddabral | 16:2159a3dc888e | 33 | unsigned int windComPin2 = photoSensor_windComp->GetSignal2(); |
hemddabral | 4:6ed99ea3bf33 | 34 | |
hemddabral | 3:5c45cb513aaf | 35 | pc.printf("\nopAmp measured voltage(mV): %u \n", opAmpVoltage); |
hemddabral | 3:5c45cb513aaf | 36 | pc.printf("\nopAmp measured Current(mA): %u \n", opAmpCurrent); |
hemddabral | 3:5c45cb513aaf | 37 | pc.printf("\nphotodiode sensor output voltage(mV): %u \n", photoSensorVoltage); |
hemddabral | 10:62f55b54ebdf | 38 | pc.printf("\nWindows comparator: signal 1 value(pin D2): %u \n", windComPin1); |
hemddabral | 10:62f55b54ebdf | 39 | pc.printf("\nWindows comparator: signal 1 value(pin D4): %u \n", windComPin2); |
hemddabral | 15:edec8fd4f69c | 40 | |
hemddabral | 13:179d5044bbc1 | 41 | dutyCycle += 0.1; |
hemddabral | 13:179d5044bbc1 | 42 | if(dutyCycle>=1) |
hemddabral | 13:179d5044bbc1 | 43 | dutyCycle -= 1; |
hemddabral | 13:179d5044bbc1 | 44 | |
hemddabral | 13:179d5044bbc1 | 45 | pc.printf("\nLED Driver: duty cycle: %.2lf percent \n", led_Driver->SetDutyCycle(dutyCycle)); |
hemddabral | 13:179d5044bbc1 | 46 | |
hemddabral | 9:9b48d36016c3 | 47 | myled = !myled; |
hemddabral | 9:9b48d36016c3 | 48 | wait(1); |
hemddabral | 4:6ed99ea3bf33 | 49 | } |
hemddabral | 0:0f16e14940d0 | 50 | } |