查看: 8077|回复: 8

[原创] 【LPC54114】+ B2.语音控制的数据采集系统

[复制链接]
  • TA的每日心情
    开心
    2025-5-29 08:54
  • 签到天数: 2992 天

    连续签到: 8 天

    [LV.Master]伴坛终老

    45

    主题

    5548

    帖子

    22

    金牌会员

    Rank: 6Rank: 6

    积分
    12035
    最后登录
    2025-5-29
    发表于 2017-4-27 20:57:56 | 显示全部楼层 |阅读模式
    本帖最后由 limale 于 2017-4-27 21:00 编辑

    上一篇帖子【LPC54114】+ B1.驱动ADS8332+官方库有bug解决了数据采样的问题,这两天又抽空把项目剩下的工作完善了一下。主要是实现了6轴力传感器的数据采集、串口wifi模块发送以及通过板载的数字麦克风进行简单的采样和停止采样的控制。原来的打算是通过语音进行控制的,开始考虑的有点儿简单,调试了两天还是有点儿问题只能等五一过后再搞了。
    下来从硬件及软件方面做个总结吧。
    1.硬件准备:
    LPC54114板卡、I2C接口的oled、6轴力传感器、传感器采集电路、两块CC3200模块。
    2.软件准备:
    KEIL5.18、SDK2.0、串口工具等。


    通过先前对这块板卡的学习,基本的准备工作都差不多了,其实这篇帖子也就是把这些功能组装起来。先来一张效果图吧。
    简单的介绍一下,以LPC54114板卡为中心,I2C接口的OLED用于显示,右下角的CC3200模块配置成客户端通过串口连接LPC54114的串口5,右上角的CC3200模块配置成服务器通过USB转串口模块连接电脑。最左边的就是6轴的力传感器包括3轴的力和3轴的力矩,它的6对查分信号通过两级放大以后送到ADS8332进行AD转换然后通过SPI接口和LPC54114进行通讯。板载的数字麦克风进行声音的采集,目前完成的是通过对声音长短的分辨来进行采集的开始和停止。
    IMG_20170427_190733.jpg

    下边是需要用到的一些IO口的配置:
    连接OLED的I2C1接口
    1. i2c_master_config_t masterConfig;
    2.         
    3.         CLOCK_AttachClk(kFRO_HF_to_FLEXCOMM1);
    4.         RESET_PeripheralReset(kFC1_RST_SHIFT_RSTn);
    5.         
    6.         IOCON_PinMuxSet(IOCON, 0, 23, 0x181);
    7.         IOCON_PinMuxSet(IOCON, 0, 24, 0x181);
    8.         

    9.         I2C_MasterGetDefaultConfig(&masterConfig);
    10.         masterConfig.baudRate_Bps = 100000U;
    11.         masterConfig.enableMaster = 1;
    12.         I2C_MasterInit(I2C1, &masterConfig, 12000000);
    复制代码
    连接ADS8332的SPI3接口,以及四个普通IO口(三个输出、一个输入)
    1. spi_master_config_t masterConfig = {0};
    2.                
    3.         /* attach 12 MHz clock to SPI3 */
    4.         CLOCK_AttachClk(kFRO12M_to_FLEXCOMM3);
    5.   /* reset FLEXCOMM for SPI */
    6.   RESET_PeripheralReset(kFC3_RST_SHIFT_RSTn);
    7.         
    8.         /* SPI2 pins */
    9.         IOCON_PinMuxSet(IOCON, 0, 14, (IOCON_FUNC2 | IOCON_MODE_PULLUP | IOCON_GPIO_MODE | IOCON_DIGITAL_EN));  /* SPI3_CS - FLASH */
    10.         IOCON_PinMuxSet(IOCON, 0, 11, (IOCON_FUNC1 | IOCON_MODE_PULLUP | IOCON_GPIO_MODE | IOCON_DIGITAL_EN));  /* SPI3_SCK        */
    11.         IOCON_PinMuxSet(IOCON, 0, 12, (IOCON_FUNC1 | IOCON_MODE_PULLUP | IOCON_GPIO_MODE | IOCON_DIGITAL_EN));  /* SPI3_MOSI       */
    12.         IOCON_PinMuxSet(IOCON, 0, 13, (IOCON_FUNC1 | IOCON_MODE_PULLUP | IOCON_GPIO_MODE | IOCON_DIGITAL_EN));  /* SPI3_MISO       */
    13.         
    14.         SPI_MasterGetDefaultConfig(&masterConfig);
    15.         masterConfig.direction = kSPI_MsbFirst;
    16.         masterConfig.polarity = kSPI_ClockPolarityActiveLow;
    17.         masterConfig.phase = kSPI_ClockPhaseFirstEdge;
    18.         masterConfig.baudRate_Bps = 1000000;
    19.         masterConfig.sselNum = (spi_ssel_t)2; // use GPIO as CS is prefer
    20.         SPI_MasterInit(SPI3, &masterConfig, CLOCK_GetFreq(kCLOCK_Flexcomm3));
    21.         
    22.         GPIO->DIR[1] &= ~(1U << ADS8332_EOC);

    23. #define ADS8332_EOC                        3                        //PIO1_3

    24. //
    25. #define ADS8332_CONVST_SET()                led_on(0)
    26. #define ADS8332_CONVST_RESET()        led_off(0)

    27. //
    28. #define ADS8332_RST_SET()                                led_on(1)
    29. #define ADS8332_RST_RESET()                        led_off(1)

    30. //
    31. #define        ADS8332_INT()                                        GPIO_ReadPinInput(GPIO, 1, 3)

    32. //
    33. #define ADS8332_CS_SET()                                led_on(2)
    34. #define ADS8332_CS_RESET()                        led_off(2)
    复制代码
    连接CC3200wifi模块的UART5
    1. #define DEMO_USART USART5
    2. #define DEMO_USART_CLK_SRC kCLOCK_Flexcomm5
    3. #define DEMO_USART_CLK_FREQ CLOCK_GetFreq(kCLOCK_Flexcomm5)

    4. #define IOCON_PIO_DIGITAL_EN          0x80u   /*!< Enables digital function */
    5. #define IOCON_PIO_FUNC1               0x01u   /*!< Selects pin function 1 */
    6. #define IOCON_PIO_INPFILT_OFF       0x0100u   /*!< Input filter disabled */
    7. #define IOCON_PIO_INV_DI              0x00u   /*!< Input function is not inverted */
    8. #define IOCON_PIO_MODE_INACT          0x00u   /*!< No addition pin function */
    9. #define IOCON_PIO_OPENDRAIN_DI        0x00u   /*!< Open drain is disabled */
    10. #define IOCON_PIO_SLEW_STANDARD       0x00u   /*!< Standard mode, output slew rate control is enabled */
    11. #define PIN18_IDX                        18u   /*!< Pin number for pin 0 in a port 0 */
    12. #define PIN20_IDX                        20u   /*!< Pin number for pin 1 in a port 0 */
    13. #define PORT0_IDX                        0u   /*!< Port index */
    14.         /* attach 12 MHz clock to FLEXCOMM0 (debug console) */
    15.   CLOCK_AttachClk(kFRO12M_to_FLEXCOMM5);

    16.   /* reset FLEXCOMM for USART */
    17.   RESET_PeripheralReset(kFC5_RST_SHIFT_RSTn);
    18.         
    19.   CLOCK_EnableClock(kCLOCK_Iocon);                           /* Enables the clock for the IOCON block. 0 = Disable; 1 = Enable.: 0x01u */

    20.   const uint32_t port0_pin18_config = (
    21.     IOCON_PIO_FUNC1 |                                        /* Pin is configured as FC0_RXD_SDA_MOSI */
    22.     IOCON_PIO_MODE_INACT |                                   /* No addition pin function */
    23.     IOCON_PIO_INV_DI |                                       /* Input function is not inverted */
    24.     IOCON_PIO_DIGITAL_EN |                                   /* Enables digital function */
    25.     IOCON_PIO_INPFILT_OFF |                                  /* Input filter disabled */
    26.     IOCON_PIO_SLEW_STANDARD |                                /* Standard mode, output slew rate control is enabled */
    27.     IOCON_PIO_OPENDRAIN_DI                                   /* Open drain is disabled */
    28.   );
    29.   IOCON_PinMuxSet(IOCON, PORT0_IDX, PIN18_IDX, port0_pin18_config); /* PORT0 PIN0 (coords: 31) is configured as FC0_RXD_SDA_MOSI */
    30.   const uint32_t port0_pin20_config = (
    31.     IOCON_PIO_FUNC1 |                                        /* Pin is configured as FC0_TXD_SCL_MISO */
    32.     IOCON_PIO_MODE_INACT |                                   /* No addition pin function */
    33.     IOCON_PIO_INV_DI |                                       /* Input function is not inverted */
    34.     IOCON_PIO_DIGITAL_EN |                                   /* Enables digital function */
    35.     IOCON_PIO_INPFILT_OFF |                                  /* Input filter disabled */
    36.     IOCON_PIO_SLEW_STANDARD |                                /* Standard mode, output slew rate control is enabled */
    37.     IOCON_PIO_OPENDRAIN_DI                                   /* Open drain is disabled */
    38.   );
    39.   IOCON_PinMuxSet(IOCON, PORT0_IDX, PIN20_IDX, port0_pin20_config); /* PORT0 PIN1 (coords: 32) is configured as FC0_TXD_SCL_MISO */
    40.         
    41.         usart_config_t config;
    42.         
    43.         USART_GetDefaultConfig(&config);
    44.         
    45.   config.baudRate_Bps = 115200;
    46.   config.enableTx = true;
    47.   config.enableRx = true;
    48.         
    49.   USART_Init(DEMO_USART, &config, DEMO_USART_CLK_FREQ);
    复制代码
    还有数字麦克风和WM8904接口
    1. #define IOCON_PIO_DIGITAL_EN          0x80u   /*!< Enables digital function */
    2. #define IOCON_PIO_FUNC1               0x01u   /*!< Selects pin function 1 */
    3. #define IOCON_PIO_FUNC2               0x02u   /*!< Selects pin function 2 */
    4. #define IOCON_PIO_FUNC4               0x04u   /*!< Selects pin function 4 */
    5. #define IOCON_PIO_FUNC5               0x05u   /*!< Selects pin function 5 */
    6. #define IOCON_PIO_INPFILT_OFF       0x0100u   /*!< Input filter disabled */
    7. #define IOCON_PIO_INV_DI              0x00u   /*!< Input function is not inverted */
    8. #define IOCON_PIO_MODE_INACT          0x00u   /*!< No addition pin function */
    9. #define IOCON_PIO_MODE_PULLUP         0x10u   /*!< Selects pull-up function */
    10. #define IOCON_PIO_OPENDRAIN_DI        0x00u   /*!< Open drain is disabled */
    11. #define IOCON_PIO_SLEW_STANDARD       0x00u   /*!< Standard mode, output slew rate control is enabled */

    12. #define PIN0_IDX                         0u   /*!< Pin number for pin 0 in a port 0 */
    13. #define PIN1_IDX                         1u   /*!< Pin number for pin 1 in a port 0 */
    14. #define PIN5_IDX                         5u   /*!< Pin number for pin 5 in a port 0 */
    15. #define PIN6_IDX                         6u   /*!< Pin number for pin 6 in a port 0 */
    16. #define PIN7_IDX                         7u   /*!< Pin number for pin 7 in a port 0 */

    17. #define PIN1_IDX                         1u   /*!< Pin number for pin 1 in a port 1 */
    18. #define PIN2_IDX                         2u   /*!< Pin number for pin 2 in a port 1 */

    19. #define PIN15_IDX                       15u   /*!< Pin number for pin 15 in a port 1 */
    20. #define PIN16_IDX                       16u   /*!< Pin number for pin 16 in a port 1 */

    21. #define PIN17_IDX                       17u   /*!< Pin number for pin 17 in a port 1 */

    22. #define PIN12_IDX                       12u   /*!< Pin number for pin 12 in a port 1 */
    23. #define PIN13_IDX                       13u   /*!< Pin number for pin 13 in a port 1 */
    24. #define PIN14_IDX                       14u   /*!< Pin number for pin 14 in a port 1 */

    25. #define PORT0_IDX                        0u   /*!< Port index */
    26. #define PORT1_IDX                        1u   /*!< Port index */
    27. //I2C³õʼ»¯
    28.   const uint32_t port1_pin1_config = (
    29.     IOCON_PIO_FUNC5 |                                        /* Pin is configured as FC4_RTS_SCL_SSEL1 */
    30.     IOCON_PIO_DIGITAL_EN |                                   /* Enables digital function */
    31.     IOCON_PIO_MODE_PULLUP |                                  /* Selects pull-up function */
    32.     IOCON_PIO_INPFILT_OFF                                    /* Input filter disabled */
    33.   );
    34.   IOCON_PinMuxSet(IOCON, PORT1_IDX, PIN1_IDX, port1_pin1_config); /* PORT0 PIN25 (coords: 3) is configured as FC4_RTS_SCL_SSEL1 */
    35.   const uint32_t port1_pin2_config = (
    36.     IOCON_PIO_FUNC5 |                                        /* Pin is configured as FC4_RTS_SCL_SSEL1 */
    37.     IOCON_PIO_DIGITAL_EN |                                   /* Enables digital function */
    38.     IOCON_PIO_MODE_PULLUP |                                  /* Selects pull-up function */
    39.     IOCON_PIO_INPFILT_OFF                                           /* Input filter disabled */
    40.   );
    41.   IOCON_PinMuxSet(IOCON, PORT1_IDX, PIN2_IDX, port1_pin2_config); /* PORT0 PIN26 (coords: 4) is configured as FC4_CTS_SDA_SSEL0 */

    42. //PDM0³õʼ»¯        
    43.   const uint32_t port1_pin15_config = (
    44.     IOCON_PIO_FUNC1 |                                        /* Pin is configured as PDM0_CLK */
    45.     IOCON_PIO_MODE_PULLUP |                                  /* Selects pull-up function */
    46.     IOCON_PIO_INV_DI |                                       /* Input function is not inverted */
    47.     IOCON_PIO_DIGITAL_EN |                                   /* Enables digital function */
    48.     IOCON_PIO_INPFILT_OFF |                                  /* Input filter disabled */
    49.     IOCON_PIO_OPENDRAIN_DI                                   /* Open drain is disabled */
    50.   );
    51.   IOCON_PinMuxSet(IOCON, PORT1_IDX, PIN15_IDX, port1_pin15_config); /* PORT0 PIN31 (coords: 13) is configured as PDM0_CLK */
    52.   const uint32_t port1_pin16_config = (
    53.     IOCON_PIO_FUNC1 |                                        /* Pin is configured as PDM0_DATA */
    54.     IOCON_PIO_MODE_PULLUP |                                  /* Selects pull-up function */
    55.     IOCON_PIO_INV_DI |                                       /* Input function is not inverted */
    56.     IOCON_PIO_DIGITAL_EN |                                   /* Enables digital function */
    57.     IOCON_PIO_INPFILT_OFF |                                  /* Input filter disabled */
    58.     IOCON_PIO_OPENDRAIN_DI                                   /* Open drain is disabled */
    59.   );
    60.   IOCON_PinMuxSet(IOCON, PORT1_IDX, PIN16_IDX, port1_pin16_config); /* PORT1 PIN0 (coords: 14) is configured as PDM0_DATA */

    61. //MCLK        
    62.   const uint32_t port1_pin17_config = (
    63.     IOCON_PIO_FUNC4 |                                        /* Pin is configured as MCLK */
    64.     IOCON_PIO_MODE_INACT |                                   /* No addition pin function */
    65.     IOCON_PIO_INV_DI |                                       /* Input function is not inverted */
    66.     IOCON_PIO_DIGITAL_EN |                                   /* Enables digital function */
    67.     IOCON_PIO_INPFILT_OFF |                                  /* Input filter disabled */
    68.     IOCON_PIO_SLEW_STANDARD |                                /* Standard mode, output slew rate control is enabled */
    69.     IOCON_PIO_OPENDRAIN_DI                                   /* Open drain is disabled */
    70.   );
    71.   IOCON_PinMuxSet(IOCON, PORT1_IDX, PIN17_IDX, port1_pin17_config); /* PORT1 PIN17 (coords: 10) is configured as MCLK */

    72. //I2S_TX_DATA
    73.   const uint32_t port1_pin13_config = (
    74.     IOCON_PIO_FUNC4 |                                        /* Pin is configured as FC6_RXD_SDA_MOSI_DATA */
    75.     IOCON_PIO_MODE_PULLUP |                                  /* Selects pull-up function */
    76.     IOCON_PIO_INV_DI |                                       /* Input function is not inverted */
    77.     IOCON_PIO_DIGITAL_EN |                                   /* Enables digital function */
    78.     IOCON_PIO_INPFILT_OFF |                                  /* Input filter disabled */
    79.     IOCON_PIO_SLEW_STANDARD |                                /* Standard mode, output slew rate control is enabled */
    80.     IOCON_PIO_OPENDRAIN_DI                                   /* Open drain is disabled */
    81.   );
    82.   IOCON_PinMuxSet(IOCON, PORT1_IDX, PIN13_IDX, port1_pin13_config); /* PORT0 PIN5 (coords: 39) is configured as FC6_RXD_SDA_MOSI_DATA */

    83. //I2S_TX_WS
    84.   const uint32_t port1_pin14_config = (
    85.     IOCON_PIO_FUNC4 |                                        /* Pin is configured as FC6_TXD_SCL_MISO_WS */
    86.     IOCON_PIO_MODE_PULLUP |                                  /* Selects pull-up function */
    87.     IOCON_PIO_INV_DI |                                       /* Input function is not inverted */
    88.     IOCON_PIO_DIGITAL_EN |                                   /* Enables digital function */
    89.     IOCON_PIO_INPFILT_OFF |                                  /* Input filter disabled */
    90.     IOCON_PIO_SLEW_STANDARD |                                /* Standard mode, output slew rate control is enabled */
    91.     IOCON_PIO_OPENDRAIN_DI                                   /* Open drain is disabled */
    92.   );
    93.   IOCON_PinMuxSet(IOCON, PORT1_IDX, PIN14_IDX, port1_pin14_config); /* PORT0 PIN6 (coords: 40) is configured as FC6_TXD_SCL_MISO_WS */

    94. //I2S_TX_SCK
    95.   const uint32_t port1_pin12_config = (
    96.     IOCON_PIO_FUNC4 |                                        /* Pin is configured as FC6_SCK */
    97.     IOCON_PIO_MODE_PULLUP |                                  /* Selects pull-up function */
    98.     IOCON_PIO_INV_DI |                                       /* Input function is not inverted */
    99.     IOCON_PIO_DIGITAL_EN |                                   /* Enables digital function */
    100.     IOCON_PIO_INPFILT_OFF |                                  /* Input filter disabled */
    101.     IOCON_PIO_SLEW_STANDARD |                                /* Standard mode, output slew rate control is enabled */
    102.     IOCON_PIO_OPENDRAIN_DI                                   /* Open drain is disabled */
    103.   );
    104.   IOCON_PinMuxSet(IOCON, PORT1_IDX, PIN12_IDX, port1_pin12_config); /* PORT0 PIN7 (coords: 41) is configured as FC6_SCK */
    复制代码
    复位以后串口0可以看到一下系统打印信息,串口5用于接口传感器数据。
    QQ截图20170427195347.jpg
    QQ截图20170427195352.jpg
    此时程序正在等待中断的产生,当数字麦克风接收到声音的变化进入5次以上10次以下的中断会开始进行数据的采集。
    QQ截图20170427195455.jpg
    QQ截图20170427195459.jpg
    当进入中断的次数大于10又归零而且小于5数据采集停止。
    QQ截图20170427195507.jpg
    QQ截图20170427195511.jpg
    现在语音控制这块儿还是第一次搞,还没有完全弄懂。等五一节之后再好好研究一下吧。
    CC3200模块的数据手册:
    USR-C322_V2.8.pdf (3.36 MB, 下载次数: 8)
    签到签到
    回复

    使用道具 举报

  • TA的每日心情
    擦汗
    2021-9-9 22:51
  • 签到天数: 415 天

    连续签到: 1 天

    [LV.9]以坛为家II

    79

    主题

    3088

    帖子

    21

    金牌会员

    Rank: 6Rank: 6

    积分
    5181
    最后登录
    2022-5-23
    发表于 2017-4-27 22:31:18 | 显示全部楼层
    赞一个
    该会员没有填写今日想说内容.
    回复

    使用道具 举报

  • TA的每日心情
    开心
    2018-6-12 12:56
  • 签到天数: 215 天

    连续签到: 1 天

    [LV.7]常住居民III

    3

    主题

    444

    帖子

    0

    金牌会员

    Rank: 6Rank: 6

    积分
    1154
    最后登录
    2021-4-29
    发表于 2017-4-28 08:34:32 | 显示全部楼层
    赞个先!
    哎...今天够累的,签到来了~
    回复

    使用道具 举报

  • TA的每日心情
    开心
    2025-5-29 08:54
  • 签到天数: 2992 天

    连续签到: 8 天

    [LV.Master]伴坛终老

    45

    主题

    5548

    帖子

    22

    金牌会员

    Rank: 6Rank: 6

    积分
    12035
    最后登录
    2025-5-29
     楼主| 发表于 2017-4-28 09:12:06 | 显示全部楼层
    谢谢支持
    签到签到
    回复

    使用道具 举报

  • TA的每日心情
    开心
    2025-5-29 08:54
  • 签到天数: 2992 天

    连续签到: 8 天

    [LV.Master]伴坛终老

    45

    主题

    5548

    帖子

    22

    金牌会员

    Rank: 6Rank: 6

    积分
    12035
    最后登录
    2025-5-29
     楼主| 发表于 2017-4-28 09:12:51 | 显示全部楼层

    谢谢支持
    签到签到
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    慵懒
    2019-11-22 09:55
  • 签到天数: 179 天

    连续签到: 1 天

    [LV.7]常住居民III

    12

    主题

    1122

    帖子

    0

    金牌会员

    Rank: 6Rank: 6

    积分
    1377
    最后登录
    2019-11-22
    发表于 2017-4-28 10:03:51 | 显示全部楼层
    楼主好厉害   学习学习
    该会员没有填写今日想说内容.
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    开心
    2019-2-14 16:49
  • 签到天数: 296 天

    连续签到: 1 天

    [LV.8]以坛为家I

    241

    主题

    2239

    帖子

    6

    金牌会员

    Rank: 6Rank: 6

    积分
    4473
    最后登录
    2020-4-14
    发表于 2017-5-15 08:14:33 | 显示全部楼层
    学习了,赞!
    回复

    使用道具 举报

  • TA的每日心情
    擦汗
    2017-4-19 13:25
  • 签到天数: 1 天

    连续签到: 1 天

    [LV.1]初来乍到

    0

    主题

    15

    帖子

    0

    注册会员

    Rank: 2

    积分
    120
    最后登录
    2017-10-8
    发表于 2017-10-7 22:28:09 | 显示全部楼层
    谢谢分享,下载来研究研究
    哎...今天够累的,签到来了1...
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    奋斗
    2018-5-16 21:35
  • 签到天数: 1 天

    连续签到: 1 天

    [LV.1]初来乍到

    2

    主题

    22

    帖子

    0

    注册会员

    Rank: 2

    积分
    107
    最后登录
    2020-7-26
    发表于 2018-5-16 21:40:34 | 显示全部楼层
    不错,多谢分享
    keep moving
    回复 支持 反对

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /3 下一条

    Archiver|手机版|小黑屋|恩智浦技术社区

    GMT+8, 2025-9-8 04:45 , Processed in 0.113080 second(s), 28 queries , MemCache On.

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.

    快速回复 返回顶部 返回列表