KIK 01 Prototype 05
Dependencies: AverageMCP3008 mbed-rtos mbed mcp3008
Fork of KIK01_Proto03 by
Diff: main.cpp
- Revision:
- 27:b07a55935230
- Parent:
- 26:866d672ba446
- Child:
- 28:387c5a6d5206
--- a/main.cpp Thu Oct 19 06:10:00 2017 +0000 +++ b/main.cpp Thu Oct 19 06:36:10 2017 +0000 @@ -2,7 +2,7 @@ * KIK01 * Kick Machine * - * 2017.10.19 Proto05: Add Noise Generator Controller + * 2017.10.19 Proto05: Add NOS01 Controller * 2017.09.16 Proto04: SPI1 for AD8402 Wein Bridge DCO & Internal DAC for Dual-OTA-VCA * 2017.07.04 Proto03: MCP4922 DCA * 2017.06.19 Proto02 @@ -30,6 +30,7 @@ #define AD8402_RMIN (50.0f) AnalogOut Dac1(PA_4); +AnalogOut Dac2(PA_5); // AD8402 SPI (SPI2) // SPI (PinName mosi, PinName miso, PinName sclk, PinName ssel=NC) @@ -49,7 +50,7 @@ // Check pins DigitalOut Dout1(PB_9); DigitalOut Dout2(PB_8); -DigitalOut Dout3(PC_9); +DigitalOut Dout3(PB_6); EnvelopeAR envelopeFrequency(5, 300, 880.0f, 120.0f, 40.0f, 0.36f, 0.1f); EnvelopeAR envelopeAmplitude(50, 200, 0.99f, 1.0f, 0.0f); @@ -95,9 +96,18 @@ AD8402Write(1, v); } -void DcaSetAmplitude(float amp) +void DcaSetAmplitude(int channel, float amp) { - Dac1.write(amp); + switch (channel) { + case 1: + Dac1.write(amp); + break; + case 2: + Dac2.write(amp * 0.8f); // Avoid LED,s Non-Linearity + break; + default: + error("DcaSetAmplitude(): invalid channel"); + } } void update() @@ -119,7 +129,8 @@ amplitude = envelopeAmplitude.getAmplitude(ticks); DcoSetFrequency(frequency); - DcaSetAmplitude(amplitude); + DcaSetAmplitude(1, amplitude); // DCO + DcaSetAmplitude(2, amplitude); // NOS01 ticks++; if (ticks >= envelopeLength) { @@ -159,7 +170,9 @@ int main() { - printf("%s %s\r\n", TITLE_STR1, TITLE_STR2); +#if UART_TRACE + printf("\r\n\n%s %s\r\n", TITLE_STR1, TITLE_STR2); +#endif SpiMAD8402.format(8, 0); SpiMAD8402.frequency(AD8402_SPI_SPEED);