Arduino的code编写,并在同一时间同时发送

编程入门 行业动态 更新时间:2024-10-12 08:18:37
本文介绍了Arduino的code编写,并在同一时间同时发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我工作的图形块的Scilab(软件类似于MATLAB)仿真环境。应该有块叫AI(模拟输入),AO,DO。此外,将有两个方案:1)上的Scilab,其中一个发送和接收数据的一侧; 2)的Arduino的传送和接收数据的一侧,之一。

I am working a graphical blocks for Scilab (software similar to MATLAB) simulation environment. There should be blocks called AI (analogue input), AO, DO. Also, there will be two programs: 1) on the side of Scilab, one which sends and receives data; 2) on the side of Arduino, one which sends and receives data.

现在我工作的Arduino侧code。它的code,应该从6个输入读取电压值,并通过串行它们发送到Scilab的同时写1/0至其产出时,它从Scilab的获取数据。在我的理解,发送/接收数据有关于针数(要知道它应该影响什么针)和价值本身的信息。此外,它应读,并在同一时间接收

Right now I am working on Arduino side code. It, the code, should read voltage values from 6 inputs and sends them to Scilab via serial and simultaneously write 1/0 to its outputs when it gets data from Scilab. In my understanding, data sent/received should have information about pin number (to know what pin it should affect) and value itself. Also, it should read and receives at the same time.

任何想法我怎么能这样做呢?帮助将非常AP preciated。谢谢你。

Any ideas how I could do it? Help would be much appreciated. Thank you.

推荐答案

您可以使用定时器中断阅读价值和通过串口发送给他们,并处理从Scilab的命令循环()如常。

You could use a timer interrupt to read the values and send them via serial and handle the commands from Scilab in loop() as usual.

我不是100%肯定是否有可能是从问题可能被打断,而在 Serial.read()。在这种情况下,你可能会一边读请求禁止中断(与检查前Serial.available()是否有什么东西读)。

I'm not 100% sure whether there could be problems from possibly being interrupted while in Serial.read(). In this case you might have to disable interrupts while reading the request (check before with Serial.available() whether there's something to read).

更多推荐

Arduino的code编写,并在同一时间同时发送

本文发布于:2023-11-24 00:27:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1623312.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:并在   Arduino   code

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!