Error creating DcMotor on MotorHat

edited July 2022 in Supported peripherals

Hello. I'm still new to this stuff and trying to work through a few bugs. I am trying to run a DcMotor through MotorHat of Waveshare. I am using Rasberry Pi4 with Bullseye11 and .Net Core 3.1.

This is the code I use to run the DcMotor

using System;
using Iot.Device.MotorHat;
public class DCMotorController : BaseClass
{
public void StartMotor()
{
using (var motorHat = new MotorHat(1600, 0x40))
{
var dcMotorOne = motorHat.CreateDCMotor(1);
dcMotorOne.Speed = 1;
Wait(1500);
dcMotorOne.Speed = 0;
}
}
}

But I am getting this error:
Unhandled exception. System.InvalidOperationException: Unexpected value of duty cycle (9766, 10280)
at Iot.Device.Pwm.Pca9685.g__OnOffToDutyCycleSampled|16_0(UInt16 onCycles, UInt16 offCycles)
at Iot.Device.Pwm.Pca9685.OnOffToDutyCycle(UInt16 on, UInt16 off)
at Iot.Device.Pwm.Pca9685.GetDutyCycle(Int32 channel)
at Iot.Device.Pwm.Pca9685PwmChannel.get_ActualDutyCycle()
at Iot.Device.Pwm.Pca9685PwmChannel..ctor(Pca9685 parent, Int32 channel)
at Iot.Device.Pwm.Pca9685.CreatePwmChannel(Int32 channel)
at Iot.Device.MotorHat.MotorHat.CreateDCMotor(Int32 motorNumber)

Comments

Sign In or Register to comment.