Please help with EMG sensor wrist strap function call

Good day, I am usually reticent to ask for help but I am banging my head against the wall on this one!The libraries referenced are included from OYMOTION's github GitHub - oymotion/gForceSDKArduino: This is gForce software development kit (SDK) for Arduino.
and written to make use of the VarSpeedServo library as well. Everything compiles correctly for an Arduino Nano v3 but the serial port monitor does not seem to show anything. Please help. I am making a free prosthetic for a friend.

AugmentArm.ino (3.11 KB)

gForceDataTypes.h (1.12 KB)

gForceAdapterC.cpp (2.15 KB)

gForceAdapterC.h (761 Bytes)

Hey please read the how to use this forum part. We have a hard time downloading code. Please post them using the bbcode tags. It helps us read it.

Here is the code for the arm so far

/*
Name: AugmentArm.ino
Created: 1/2/2019 8:02:26 PM
Author: diego
/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SoftwareSerial.h>
#include <VarSpeedServo.h>
#include <gForceAdapterC.h>
#define Timeout 1000
SoftwareSerial gforceSerial(2, 4);
/
returns char count */
int getChar(unsigned char *data)
{
int ret = gforceSerial.read();
if (ret == -1)
return 0;
data = (unsigned char)ret;
return 1;
}
/
returns System time */
unsigned long int getMillis(void)
{
return millis();
}
VarSpeedServo PinkyServo;
VarSpeedServo RingServo;
VarSpeedServo MiddleServo;
VarSpeedServo IndexServo;
VarSpeedServo ThumbServo;
int gesture = 0;
int open = 180;
int closed = 0;
int fast = 240;
int slow = 45;
// the setup function runs once when you press reset or power the board
void setup() {
Serial.begin(115200);
gforceSerial.begin(115200);
}
// the loop function runs over and over again until power down or reset
void loop() {
PinkyServo.attach(10);
RingServo.attach(9);
MiddleServo.attach(6);
IndexServo.attach(5);
ThumbServo.attach(3);
struct GF_Data gForceData;
struct GF_Euler Euler;
if (OK == GFC_GetgForcedata((&gForceData), Timeout)) {

GF_Gesture gesture;
}
switch (gForceData.type) {

case GF_Data::QUATERNION:

GFC_QuaternionToEuler(&(gForceData.value.quaternion), &Euler);

break;

case GF_Data::GESTURE:

gesture = gForceData.value.gesture;

if (gesture == GF_FIST) {
PinkyServo.write(closed, slow);
RingServo.write(closed, slow);
MiddleServo.write(closed, slow);
IndexServo.write(closed, slow);
ThumbServo.write(closed, slow);
Serial.print("Fist Shape");
}
else if (gesture == GF_SPREAD) {
PinkyServo.write(open, slow);
RingServo.write(open, slow);
MiddleServo.write(open, slow);
IndexServo.write(open, slow);
ThumbServo.write(open, slow);
Serial.print("Spread Shape");
}
else if (gesture == GF_WAVEIN) {
PinkyServo.write(closed, fast);
RingServo.write(closed, fast);
MiddleServo.write(closed, fast);
IndexServo.write(closed, fast);
ThumbServo.write(closed, fast);
Serial.print("Wave In Shape");
}
else if (gesture == GF_WAVEOUT) {
PinkyServo.write(open, fast);
RingServo.write(open, fast);
MiddleServo.write(open, fast);
IndexServo.write(open, fast);
ThumbServo.write(open, fast);
Serial.print("Wave Out Shape");
}
else if (gesture == GF_PINCH) {
PinkyServo.write(open, slow);
RingServo.write(open, slow);
MiddleServo.write(open, slow);
IndexServo.write(closed, slow);
ThumbServo.write(closed, slow);
Serial.print("Pinch Shape");
}
else if (gesture == GF_SHOOT) {
PinkyServo.write(closed, slow);
RingServo.write(closed, slow);
MiddleServo.write(closed, slow);
IndexServo.write(open, slow);
ThumbServo.write(open, slow);
Serial.print("Shoot Shape");
}
else if (gesture == GF_RELEASE) {
PinkyServo.write(open, fast);
RingServo.write(open, fast);
MiddleServo.write(open, fast);
IndexServo.write(open, fast);
ThumbServo.write(open, fast);
Serial.print("Release Shape");
}
}
}

I'm sorry this is the very first time I've ever used a forum lol
here is the gforceadapterC.h

#ifndef _GFORCEADAPTERC_H
#define _GFORCEADAPTERC_H

#include "gForceDataTypes.h"

#ifndef NULL
#define NULL ((void*)0)
#endif

#ifndef BOOL
#define BOOL int
#endif

#ifndef TRUE
#define TRUE ((BOOL)1)
#endif

#ifndef FALSE
#define FALSE ((BOOL)0)
#endif

#ifdef __cplusplus
extern "C" {
#endif

/* Implement me: get char that usart2 receve from gforcejoint */
int getChar(unsigned char *data);

/* Implement me: get system run time */
unsigned long int getMillis(void);

enum GF_Ret GFC_GetgForcedata(struct GF_Data *gForceData, unsigned long timeout);

enum GF_Ret GFC_QuaternionToEuler(const struct GF_Quaternion *quat, struct GF_Euler *euler);

BOOL GFC_GetGesture(enum GF_Gesture gesture, unsigned long timeout);

#ifdef __cplusplus
}
#endif

#endif

Hello Diego,

Could you please explain a little better how does your setup look like?

I'm also having some problems getting information about the gforcce via serial port.

My current setup is connecting the tiny green PCB they provide with a USB to serial converter.
Then I use a serial terminal to see what I get, and at the rated serial speed (115200), I only get random characters.

So it seems that already one of the problems is the way the data is received by the serial port...
Let's put some information together to make this run!

Cheers!

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html . Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom... :slight_smile: