Answer the question
In order to leave comments, you need to log in
What happens to the servo on PanStamp?
I'm having trouble with a PanStamp project https://github.com/panStamp/panstamp/wiki
I'm transmitting from one PanStamp device to another via radio, a continuous degree of rotation angle for sevo (from 0 to 180 degrees.) The servo twitches at the same time the video is visible https://yadi.sk/i/2ikGURLcfTGND
1) When I connect the servo directly to the potentiometer without radio communication, there is no such problem, it smoothly rotates by a given degree.
2) During data transfer with a connected servo, some left characters are visible on the serial port during twitching. When I turn off the server, these characters do not appear.
3) I checked 3 servos (all working) all have the same problem.
4) Noisy data from the potentiometer is excluded. I average them through the "Average" function before sending them to the receiver.
5) I made the harness for the voltage stabilizer for the servo with two 470 mfarad conduits
Transmitter code:
#define POT_PIN 0 // потенциометр
#define K 0.1 // коэфициэнт усреднения
#define RFCHANNEL 0 // Let's use channel 0
#define SYNCWORD1 0xB5 // Synchronization word, high byte
#define SYNCWORD0 0x47 // Synchronization word, low byte
#define SOURCE_ADDR 4 // Sender address
#define DESTINATION_ADDR 5 // Receiver address
CCPACKET txPacket; // Задаем объект txPacket
int newX, oldX; // Переменные для усреднения
byte POT_NEW; // Рабочее (усредненное) значение потенциометра
void setup()
{
// panstamp.setHighTxPower (); // режим мах мощности 10 дБ
panstamp.radio.setChannel(RFCHANNEL);
panstamp.radio.setSyncWord(SYNCWORD1, SYNCWORD0);
panstamp.radio.setDevAddress(SOURCE_ADDR);
panstamp.radio.setCCregs();
// Откючение адреса, устройство будет получать/отправлять на любое устройство
panstamp.radio.disableAddressCheck();
}
void loop()
{
txPacket.length = 2; // Размер пакета
Average(analogRead(POT_PIN));
// txPacket.data[0] = DESTINATION_ADDR; // Первый байт данных должен быть адресом назначения
txPacket.data[1] = POT_NEW; // Передаем байту 1 переменную
panstamp.radio.sendData(txPacket); // Посылаем пакет
}
byte Average(int x)
{
newX=(x*K)+(oldX*(1.0-K));
oldX = newX;
POT_NEW=map(newX, 0, 1013, 0, 180);
return POT_NEW;
}
#include <Servo.h>
#include <HardwareSerial.h>
#define RFCHANNEL 0 // Let's use channel 0
#define SYNCWORD1 0xB5 // Synchronization word, high byte
#define SYNCWORD0 0x47 // Synchronization word, low byte
#define SOURCE_ADDR 4 // Sender address
#define DESTINATION_ADDR 5 // Receiver address
int i;
int S_POS; // Позиция сервапривода
int S_PIN=9; // Серво пин
Servo myservo;
void rfPacketReceived(CCPACKET *packet) // функция приема данных
{
if (packet->length > 1)
{
// packet.data[0]; // Первый байт адрес устройства
S_POS=packet->data[1]; // Данные с потенциометра
}
}
void setup()
{
// Инициализация приемника
panstamp.radio.setChannel(RFCHANNEL);
panstamp.radio.setSyncWord(SYNCWORD1, SYNCWORD0);
panstamp.radio.setDevAddress(SOURCE_ADDR);
panstamp.radio.setCCregs();
myservo.attach(S_PIN); // инициализация сервопривода
Serial.begin(9600);
// Выключаем адресацию устройств, приемник будет принимать от любого устр
panstamp.radio.disableAddressCheck();
// Обратный вызов RF
panstamp.setPacketRxCallback(rfPacketReceived);
}
void loop() {
myservo.write(S_POS);
Serial.println(S_POS);
}
Answer the question
In order to leave comments, you need to log in
observed a similar situation, in my case it turned out that the power supply to the servo was sinking and therefore there were problems
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question