Arduino Due; Virtualwire and Servos library problems

Hello,

I recently started a project to make a RC boat. I originally had an Uno as the controller and a Mega 2560, the Uno had some potentiometers which I then had transmitted their values, using the Virtualwire library. The Mega would then use the value and turn the servo etc. Except the Servo and Virtualwire libraries did not work. I did some research and found out they used the same timer so I used the Servotimer2 library. It worked but was delayed, I am guessing because it did not have the full 16-bit timer so I bought an Arduino Due because of its high performance and specifications. I just assumed that the Due had enough computing power to run the Virtualwire and Servo libraries together but it does not look like it.

Can anyone helped me out?

If you need the code tell me

I just assumed that the Due had enough computing power to run the Virtualwire and Servo libraries together but it does not look like it.

Computing power and independent timers are two different things.

If you need the code tell me

That depends. Do you need help?

#include <VirtualWire.h> //Virtual Wire Library
#include <Servo.h> //Servo Library

int RX_PIN = 11; //Reciever pin

Servo stern; //Stern Servo
int sternDegree; //Stern Degree

typedef struct roverRemoteData //Reciever setup
{
int    TX_ID; //Transmitter ID
int    sternData; //Data package
int    inData; //Data package
};

void setup() 
{
Serial.begin(9600); //Serial setup
vw_setup(2000); //Virtual wire setup
vw_set_rx_pin(RX_PIN); //Reciever pin
vw_rx_start(); //Reciever setup

stern.attach(8); //Servo steup

pinMode(12, OUTPUT);
} 

void loop()
{ 
//Reciever
struct roverRemoteData receivedData;
uint8_t rcvdSize = sizeof(receivedData);
vw_wait_rx();

if (vw_get_message((uint8_t *)&receivedData, &rcvdSize)) 
{ 
 Serial.println("Recieved");
 sternDegree = receivedData.sternData;
 stern.write(sternDegree);
   
 if(receivedData.inData == 1) 
   digitalWrite(12, 1); 
 if(receivedData.inData == 0) 
   digitalWrite(12, 0); 
} 
//Reciever
}

Yes I would your help, by the way the error code is:

Arduino: 1.6.7 (Windows 10), Board: "Arduino Due (Programming Port)"

D:\Arduino Script\VW_Reciever_Analog\VW_Reciever_Analog.ino:14:1: warning: 'typedef' was ignored in this declaration [enabled by default]

};

^

C:\Program Files (x86)\Arduino\libraries\VirtualWire\VirtualWire.cpp:16:26: fatal error: util/crc16.h: No such file or directory

#include <util/crc16.h>

^

compilation terminated.

exit status 1
Error compiling.

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

So, it appears that VirtualWire is not designed to work on the Due. It's marked obsolete, anyway. So, why not upgrade to RadioHead - it's replacement?

The VW library depends on util/crc16.h , which is part of the standard avr libraries. That isn't part of the standard SAM libraries. Library compatibility with the Due (and other non-AVR boards) is pretty poor - basically anything where you have to peek below the surface (which is usually what you have a library for) needs to be significantly changed for Due, and since the Due never reached anything close to the popularity of AVR-based Arduinos, people don't bother.

I think the original problem is worth more investigation, before concluding that you don't have enough processing power. I would be shocked if this couldn't be made to work on the usual AVR hardware, because my "learning exercise" AzzyRF ( GitHub - SpenceKonde/AzzyProjects: (not expected to be useful to anyone else) - no, it hasn't been library-ified and is largely undocumented) could do something like that no problem (it doesn't use a timer either). You do realize, though, that cheapo-RF things send the message a few times, because ASK/OOK is a bit flaky to begin with, and the transmitters and receivers are often utter garbage. This introduces a delay that may be perceptible, particularly if you're sending it a whole bunch of times to ensure receipt, or if the receiver is echoing back some response before telling your program what it received.

I don't wanna sound like a newbie or whatever but do you have a solution?

DrAzzy:
Library compatibility with the Due (and other non-AVR boards) is pretty poor

It doesn't necessarily have to be that way. VirtualWire is one of many I've ported to Teensy 3.x. It's really not very difficult, but you do have to consider "Arduino compatible" to mean more than only the libraries which ship with the Arduino IDE.