Change pin mode for Arduino in Simulink
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I'm trying to compile a Simulink program that uses a stateflow chart with an Arduino board as my target. I keep getting the error: "Both the 'Digital Output' block and the 'Digital Input' block use the pin number 7. Change the value of the parameter 'Pin number' on the 'Digital Output' block, or the value of the parameter 'Pin number' on the 'Digital Input' block so that the parameter conflict is resolved." However, I need to be able to change the pin mode in my application. A pulse has to be sent to the ultrasonic sensor and then it has to wait for a return pulse. I'm not sure how to change the pin mode in Simulink from output to input. Any help on this would be appreciated. Thanks.
0 Commenti
Risposta accettata
Ryan G
il 21 Set 2012
What's going on is each pin can only do 1 thing, as pin 7 can ONLY be used for output or ONLY be used for input.
Looking at this ultrasound sensor and the code that follows, they are discretely switching the pin 7 later on. There is an answer here which says this cannot be done directly.
There are 2 options as I see it:
1) Instead of using the Simulink I/O blocks, you can write an s-function that will perform the digital i/o
2) Find a sensor that uses 2 pins instead of 1.
You should have the code for the digital I/O already (I think that's what's on the sensor link above) so all you would need to do is implement that via s-function.
8 Commenti
Ryan G
il 28 Set 2012
It's great to hear that you worked this out. May I suggest you make an enhancement request since it looks like using the same pin I/O is a common workflow for this type of sensor.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Arduino Hardware in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!