- Joined
- Jul 4, 2008
- Messages
- 2,499
- Points
- 113
So a little update on the scaler project. I am in the final stages of assembling a counting program to simply display the output on a Mac. This program is using C++ assembly language to use the incoming data from the Yocto-PMW-Rx and modify its reporting behaviour.
Hz = CPS , edge count is divided by 2 to give raw Counts.
All this program is designed to to is display at the moment, no graphing or logging. Xcode has made this assembly process difficult as I can assemble it but cannot get the program to be freestanding nor display the incoming data.
The dependencies are listed on the top part of the C++ code.
If anyone has a background in C++ / programming would like to offer their recommendations I'm all ears. Eventually I'd like to be able to log and graph the output, maybe even be able to convert the CPS/ Counts to a metered dose. The raw counts could also be on a timer.
:thinking:
Hz = CPS , edge count is divided by 2 to give raw Counts.
All this program is designed to to is display at the moment, no graphing or logging. Xcode has made this assembly process difficult as I can assemble it but cannot get the program to be freestanding nor display the incoming data.
The dependencies are listed on the top part of the C++ code.
If anyone has a background in C++ / programming would like to offer their recommendations I'm all ears. Eventually I'd like to be able to log and graph the output, maybe even be able to convert the CPS/ Counts to a metered dose. The raw counts could also be on a timer.
:thinking:
#include "yocto_api.h"
#include "yocto_pwminput.h"
#include <iostream>
#include <stdlib.h>
using namespace std;
static void usage(void)
{
cout << "usage: demo <serial_number> " << endl;
cout << " demo <logical_name>" << endl;
cout << " demo any (use any discovered device)" << endl;
u64 now = yGetTickCount();
while (yGetTickCount() - now < 3000) {
// wait 3 sec to show the message
}
exit(1);
}
int main(int argc, const char * argv[])
{
string errmsg;
string target;
YPwmInput *pwm;
YPwmInput *pwm1;
YPwmInput *pwm2;
YModule *m;
if (argc < 2) {
usage();
}
target = (string) argv[1];
YAPI:isableExceptions();
// Setup the API to use local USB devices
if (YAPI::RegisterHub("usb", errmsg) != YAPI_SUCCESS) {
cerr << "RegisterHub error: " << errmsg << endl;
return 1;
}
if (target == "any") {
// retreive any pwm input available
pwm = YPwmInput::FirstPwmInput();
if (pwm == NULL) {
cerr << "No module connected (Check cable)" << endl;
exit(1);
}
} else {
// retreive the first pwm input from the device given on command line
pwm = YPwmInput::FindPwmInput(target + ".pwmInput1");
}
// we need to retreive both channels from the device.
if (pwm->isOnline()) {
m = pwm->get_module();
pwm1 = YPwmInput::FindPwmInput(m->get_serialNumber() + ".pwmInput1");
pwm2 = YPwmInput::FindPwmInput(m->get_serialNumber() + ".pwmInput2");
} else {
cerr << "No module connected (Check cable)" << endl;
exit(1);
}
while (pwm1->isOnline()) {
cout << "PWM1 : " << pwm1->get_frequency() << " CPS " << pwm1->get_dutyCycle()
<< " % " << pwm1->get_pulseCounter()/2 << "Counts " << endl;
cout << "PWM2 : " << pwm2->get_frequency() << " CPS " << pwm2->get_dutyCycle()
<< " % " << pwm2->get_pulseCounter()/2 << " Counts " << endl;
cout << " (press Ctrl-C to exit)" << endl;
YAPI::Sleep(1000, errmsg);
}
cout << "Module disconnected" << endl;
yFreeAPI();
return 0;
}