Current reading

General discussion of using Roboclaw motor controllers
Post Reply
Nita
Posts: 1
Joined: Wed May 11, 2022 12:12 pm
Current reading

Post by Nita »

Hi, I'm using Roboclaw 2x45A to control one 12VDC motor. Roboclaw is connected to Arduino Mega through packet serial communication. I was trying to read a current of motor one but the value seems to be wrong. While the motor was running or not moving at all, the current values which printed to a terminal(code below) were always the same at 145.

However, I could see changes in 'motor1current' on a scope on BasicmicroMotion software but I have no idea why the value on a terminal is always the same. Could you please suggest how to solve this issue?

Thank you.

Code: Select all

#include <SoftwareSerial.h>
#include "RoboClaw.h"

#define address 0x80

SoftwareSerial serial(10,11);  
RoboClaw roboclaw(&serial,10000);

int16_t *c1p, *c2p;

void setup() {
  Serial.begin(38400);
  roboclaw.begin(38400);
}
void loop() {
    roboclaw.ForwardM1(address, 50);
    roboclaw.ReadCurrents(address,*c1p,*c2p);
    Serial.print("CurrentM1:");
    Serial.print(*c1p);
    Serial.print("\n"); 
}
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Current reading

Post by Basicmicro Support »

ReadCurrents uses References to variables for M1 and M2 current, NOT pointers. Do not use the "*" in your code. Remember Arduino code is basically C++.

Post Reply