.ino for PCB+MD13S+Danfoss valve

Not with the md13s it would demand a Cytron like MMD10a, cytron 10A 5-30V Dual Channel DC Motor Driver, which have 2 pwm inputs.
And yes its D5 then.
So ends up with buying a IBT-2 I think :slight_smile:
If you think IBT-2 is too bulky, just remove heatsink or replace it with a piece of metal(which I have), that would be sufficient cooling for valve spool drive.My IBT-2 didn´t even have cooler paste under the heatsink! OH and the Danfoss would definitely not need cooling on IBT-2 (Danfoss says Signal current at rated voltage 0.25 mA to 0.70 mA)

If you put a 50% duty cycle across the solenoid you will have 6 v across it, All you need is half of the cytron. Super simple setup.

1 Like

Yes, but U DC needs 12V and md13s can’t supply that simultaneously with 6V to U S. Am I right?
So 12V needs to be supplied from other source, through relay for example.
Simple maybe, but not super simple? :grin:

I believe you are right, just tried to figure out where it is written in coffeetrac ino
it says to center danfoss valve, but I did not find how :frowning:

// Reset Output
digitalWrite(LED_PIN, 0); // Turn off Autosteer LED
digitalWrite(DIR_PIN, 0); // Set Motordir to left //turn off PWM Coil 2 // Turn off Danfoss Valve
pwmDrive = 0; // turn Motor off //turn off PWM Coil 1 // Center Danfoss Valve
motorDrive();

min duty cycle pwmDrive = -255 ,max duty cycle pwmDrive = 255; , pwmDrive = 0; motor left 50% duty cycle ( center Danffos valve).

So we must put that line in the ino.
But I find it strange that this line from grabik or something else does not already take care of that issue in an ino where one have the ability choose nr. 4: // 4 = Danfoss Valve PVE A/H/M + IBT_2 Driver.

How does it then work together with motordrive () or Flow or somewhere else where the calculation of pwm is done.
Or is the demand for steering a Duty cycle demand? perhaps from AOG?

Are you able to do those mods to the ino?

Probably not, as I don´t understand what is going on.
Hope Kaupoi can as he/his friend is the one in need.
Reason to post here was that I remembered seeing the danfoss line in the coffeetrac_button.ino I used on my first setup.
I forgot to post the link to coffeetrac ino 3 days ago!
The latest coffetrac ino (august 2019)can be downloaded here: Coffeetrac · GitHub
It still contains the ability to choose danfoss, I just cant get where the ofset of the pwm is done (not the full power to drive the danfoss valve, I can see where that is turned on and off)
And as mentioned earlier Weder must know how he did it.

I’ve tried to learn to read the code, but I just do not understand it. Sorry.
I’m still waiting for someone to add the steering wheel encoder function to PCBv2.ino. I’d like to use it on my own devices instead of the coffeetrac button.ino. But that’s another story. :grin:

@Kaupoi well i’m in the process of rewriting a lot. Going to make that ino about 10% of the size it is now. It’s too frickin complicated for a piece of software that turns a motor left and right.

1 Like

Maybe it is enough to copy the 4 or 5 lines in coffeetrac ino, where the word encapin appears, and put them in pcbv2 ino about the same places. The D2 pin doesn´t seem to be used in pcbv2 ino.

And also this part from setup zone.

#define SWEncoder 0 // Steering Wheel ENCODER Installed
#define pulseCountMax 3 // Switch off Autosteer after X Pulses from Steering wheel encoder

There are a few places. Can you just use the coffeetrac ino?

Yes I can. But doesn’t pcbv2.ino have better roll filtering?

File Autosteer_switch-master.zip unzip and open I arduino.

In file “PID.ino”

write on botom file, or copy-paste:

//=========================================
#if (Output_Driver == 4) //PWM 50% if pwmDrive ~ 0 , PWM 0% if pwmDrive -255 …
void motorDrive(void)
{// Used with Danffos valve 50% pwm off valve

pwmDanffos = (pwmDrive/2)+128;

if(pwmDanffos > 195) pwmDanffos = 195; // max 0,75 U , PWM 75%
if (pwmDanffos < 1 ) pwmDanffos = 48; // min 0,25 U ,PWM 25%

analogWrite(PWM1_PIN, pwmDanffos);

}
#endif

//==========================================

In file “Autosteer swetch” on top file write “4” :

#define Output_Driver 4

same file, need add “pwmDanffos = 0 “ :

//pwm variables
int pwmDrive = 0, drive = 0, pwmDisplay = 0 ,pwmDanffos = 0;
float pValue = 0, iValue = 0, dValue = 0;

Need test and PWM duty cycle should have range between 25% to 75%.

looks fine and I think I understand the settings. Except where the numbers -255 and 255 come from?
And please spell the company name Danfoss correct :slight_smile:

PID.ino

PID calculation:

*//Proportional
pValue = steerSettings.Kp * steerAngleError *steerSettings.Ko;

/* //Derivative
dError = steerAngleError - lastLastError;
dValue = Kd * (dError) * Ko;

//save history of errors
lastLastError = lastError;
lastError = steerAngleError;
*/

drive = pValue;// + dValue;
pwmDrive = (constrain(drive, -255, 255));

//add throttle factor so no delay from motor resistance.
if (pwmDrive < 0 ) pwmDrive -= steerSettings.minPWMValue;
else if (pwmDrive > 0 ) pwmDrive += steerSettings.minPWMValue;

if (pwmDrive > 255) pwmDrive = 255;
if (pwmDrive < -255) pwmDrive = -255;
*

8 byte PWM resolution on arduino nano(255) , for driver direction DIR pin, and PWM ,DIR pin LOW left side -255 max write to PWM 255 , right side DIR pin HIGH 255 max write to PWM 255 for max duty cycle.

For Danfoss valve not need DIR pin for change direction.

If max left from PID calculation “pwmDrive” = -255

from code pwmDanffos = (pwmDrive/2)+128;

(-255/2) + 128 = ~ 0 min duty cycle

if max right PID calculation “pwmDrive” = 255

(255/2) + 128 = ~ 255 max PWM duty cycle

If pwmDrive from PID calculation 0 , no stering error PWM 128 , valve close

sorry about my english

1 Like

PWM to Voltage Converter Module 0%-100% to 0-10V

I don’t understand the code at all, but thanks anyway :smiley:
I wouldn’t recommend using switch.ino with hydraulic steering. Maybe some day, someone will put that code in the PCBv2.ino :wink:

For the Danfoss valve, the mentioned converter is not needed and can only handle 100 mA and danfoss uses up to 700 mA. So we must use a motorcontroller as “pwm converter”.
On the signal pin (U s) It needs between 25 and 75 % of supply voltage, so in our case we would probably have 12 v on supply pin U dc), which demands a feed of something between 3v and 9v to the input/signal pin on the danfoss head to control the valve.