Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: HIDScope MODSERIAL QEI biquadFilter mbed
Fork of frdm_Motor_V2_3 by
main.cpp
- Committer:
- Rvs94
- Date:
- 2015-09-28
- Revision:
- 1:48aba8d5610a
- Parent:
- 0:284ed397e046
- Child:
- 2:099da0fc31b6
File content as of revision 1:48aba8d5610a:
#include "mbed.h"
#include "MODSERIAL.h"
#include "HIDScope.h"
#include "QEI.h"
Serial pc(USBTX, USBRX); // tx, rx
DigitalOut led(LED_RED);
DigitalOut motor2direction(D4); //D4 en D5 zijn motor 2 (op het motorshield)
PwmOut motor2speed(D5);
DigitalIn button1(SW3);
DigitalIn EncoderA(D3);
DigitalIn EncoderB(D2);
QEI Encoder(D3, D2, NC, 32);
HIDScope scope(3);
Ticker ScopeTime;
float Aantal_Degs;
float Aantal_pulses;
void ScopeSend()//Functie die de gegevens voor de scope uitleest en doorstuurt
{
scope.set(0, motor2direction.read());
scope.set(1, motor2speed.read());
scope.set(2, Aantal_Degs);
Aantal_Degs = Encoder.getPulses()*360/31/131;
scope.send();
}
int main()
{
motor2direction = 0;
motor2speed = 0;
led = 1;
pc.baud(115200);
pc.printf("Tot aan loop werkt");
ScopeTime.attach_us(&ScopeSend, 10e4);
while (true)
{
motor2direction = 1;
motor2speed = 0.5f;
wait(1);
motor2direction = 0;
motor2speed = 0.5f;
wait(1);
}
}
