The Netduino forums have been replaced by new forums at community.wildernesslabs.co.
This site has been preserved for archival purposes only
and the ability to make new accounts or posts has been turned off.
I've made this little program that should run a motor when I press the onboard button, stop when I press it again, and change direction when I press the button again. And so on.
However, I believe I've added all toolbox-files I need, but when I deploy it to the Netduino (Plus) it just quits. Visual Studio won't even show my Debug.Print() messages...
Am I doing something wrong?
Imports Microsoft.SPOT
Imports Microsoft.SPOT.Hardware
Imports SecretLabs.NETMF.Hardware
Imports SecretLabs.NETMF.Hardware.Netduino
Imports Toolbox.NETMF.Hardware
Module Main
Dim btn As New InterruptPort(Pins.ONBOARD_SW1, False, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeHigh)
Dim MotorDriver As SN754410 = New SN754410(Pins.GPIO_PIN_D6, Pins.GPIO_PIN_D7, Pins.GPIO_PIN_D5, Pins.GPIO_PIN_D4)
Dim bolForward As Boolean = True
Dim bolRunning As Boolean = False
Sub Main()
Debug.Print("Starting up...")
Debug.Print("Adding handler to button...")
AddHandler btn.OnInterrupt, AddressOf btn_OnInterrupt
Debug.Print("Setting motors to 0...")
MotorDriver.SetState(SN754410.Motors.Motor1, 0)
MotorDriver.SetState(SN754410.Motors.Motor2, 0)
Debug.Print("Done!")
Thread.Sleep(Timeout.Infinite)
End Sub
Private Sub btn_OnInterrupt(ByVal data1 As UInteger, ByVal data2 As UInteger, ByVal time As DateTime)
Debug.Print("Button pressed!")
Dim power As SByte = 100
If Not bolForward Then power = -power
bolRunning = Not bolRunning
bolForward = Not bolForward
If bolRunning Then
MotorDriver.SetState(SN754410.Motors.Motor1, power)
Else
MotorDriver.SetState(SN754410.Motors.Motor1, 0)
End If
End Sub
End Module
I even tried to update to RC4, but the same thing happens...
I'm sorry to hear that! What motor shield do you use?
You're using an older version of my class by the way. Shouldn't mind for it's workings, but the class name SN754410 is changed into HBridge in changeset 12473 since it better describes it's functionality.
However, I believe I've added all toolbox-files I need, but when I deploy it to the Netduino (Plus) it just quits. Visual Studio won't even show my Debug.Print() messages...
Debug.Print shows in the Immediate Window in VB at the moment I noticed. Not in the Debug window where it should be expected.
Keep in mind VB support is still in beta.
Press Debug -> Windows -> Immediate (or press Ctrl+G) to show this window.
Just had an idea... You're using 4.2 right? You downloaded the latest SDKs?
The current Netduino 4.2RC4 firmware is compatible with the .NETMF SDK 4.2 RTM, but not the 4.2 QFE1 version. Perhaps you should downgrade your SDK on your PC. See http://netmf.codeple...ases/view/52341 for the right download link.
OK, I feel rather stupid as I hadn't installed the latest SDK (RTM). Now I have, but that didn't help. I also made sure I used the lastet version of the Toolbox (from here), but still no luck.
It's strange cause I don't see HBridge anywhere...
When I deploy my program to the device, it is stuck on with the blue light just shining on. It doesn't turn of like it should. I'm sure it's just me being an idiot as usual, but I don't know what I'm doing wrong.
> When I deploy my program to the device, it is stuck on with the blue light just shining on
That can have a couple of causes, and probably not code depended. A few things I wish to know to help you out:
What motor shield do you use? There are a couple, with different pin layouts.
Can you start MFDeploy.exe (probably in C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Tools)
Then press F5 on your keyboard and the reset-button on your Netduino. Can you post the output here?
Then what is going on? I just downloaded the latest version.
> When I deploy my program to the device, it is stuck on with the blue light just shining on
That can have a couple of causes, and probably not code depended. A few things I wish to know to help you out:
What motor shield do you use? There are a couple, with different pin layouts.
Can you start MFDeploy.exe (probably in C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Tools)
Then press F5 on your keyboard and the reset-button on your Netduino. Can you post the output here?
1. I use an L298N, powered from the Netduino using 12V (as the motor is 12V).
Can you start MFDeploy.exe (probably in C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Tools)
Then press F5 on your keyboard and the reset-button on your Netduino. Can you post the output here?
OK, tried that twice. The first time my computer just rebooted without warning.
So I let the computer start up, removed the motor shield and tried again. This time I got a blue screen...
So I let the computer start up, removed the motor shield and tried again. This time I got a blue screen...
I know about BSOD issues as described at .NET Micro Framework issue 1049 which is not code depending. Annoying that it now blocks some diagnostics.
I -think- there's still a dependency issue somewhere, but hard to put my finger on it if I don't see debugging output. Have you checked the Intermediate window, or didn't you got that far?
I -think- there's still a dependency issue somewhere, but hard to put my finger on it if I don't see debugging output. Have you checked the Intermediate window, or didn't you got that far?
VB always outputs to the Immediate window, so I always check that. There's nothing there, which I also find strange. It seems like the program crashes before it is fully executed, which backs up your dependency theory...
VB always outputs to the Immediate window, so I always check that. There's nothing there, which I also find strange. It seems like the program crashes before it is fully executed, which backs up your dependency theory...
Could you, just to rule stuff out, flash everything back to 4.1 and try to get some info from MFDeploy?
I know you want to program in VB, so you need 4.2, but just to be sure firmware flashing works.
After that, flash back to the latest 4.2 build.
I flashed back to 4.1 just to be sure. Then I flashed 4.2 RC1. I deployed a simple program and that worked. I tried flashing my motor program, and that failed like before.
What is the direct link to the 4.2 SDK that I should use? I downloaded this named "SDK" from the link you posted above, here.
I have attached the solution below. If you have the time it would be great if you could take a look. I'm sure I'm missing something simple, but what?
Hi Moskus,
Could you try it with this file?
I sometimes have the feeling some stuff is cached in /obj/ and /bin/, which I often remove when in trouble. You could try that too.
Could you try it with this file?
I sometimes have the feeling some stuff is cached in /obj/ and /bin/, which I often remove when in trouble. You could try that too.
That solution worked! What did you do (I see the HBridge now)?
(And what did I do wrong?)
THANK YOU!
EDIT: The motors seems to be running when I connect the power until the program starts. Is there any way to prevent this?
I updated the DLLs to the latest version (and the be/le versions), just to be sure, and removed the obj and bin folders.
I thought I downloaded the latest version.... I need to check that yet again.
And you are quick, responed before my edit kicked in: EDIT: The motors seems to be running when I connect the power until the program starts. Is there any way to prevent this?
And you are quick, responed before my edit kicked in: EDIT: The motors seems to be running when I connect the power until the program starts. Is there any way to prevent this?
Indeed
Glad I could help you come this far though!
Hi Stephen,
First of thanks for providing the samples you have, helpful for someone starting out like myself.
I'm also attempting to get the HBridge Motor driver working and am having issues but with the NetduinoGo shield base. I'm using an H-Bridge SN754410 and have copied the schematics you have provided on my bread board connecting it to my shield base. Nothing seems to happen at all
Here's my app modified slightly from your sample attempting to get it to work with the netduino go.
public static void Main()
{
var sb = new ShieldBase(GoSockets.Socket5);
// Defines the H-Bridge IC on the correct pins
var motorDriver = new HBridge(sb.PWMChannels.PWM_4, sb.Pins.GPIO_PIN_D5, sb.PWMChannels.PWM_3, sb.Pins.GPIO_PIN_D2);
// Motor 1 half speed backward
motorDriver.SetState(HBridge.Motors.Motor1, -50);
// Motor 2 half speed forward
motorDriver.SetState(HBridge.Motors.Motor2, 50);
// Lets run for 5 seconds
Thread.Sleep(5000);
// Motor 1 full speed backward
motorDriver.SetState(HBridge.Motors.Motor1, -100);
// Motor 2 full speed forward
motorDriver.SetState(HBridge.Motors.Motor2, 100);
// Lets run for 5 seconds
Thread.Sleep(5000);
// Stops both motors
motorDriver.SetState(HBridge.Motors.Motor1, 0);
motorDriver.SetState(HBridge.Motors.Motor2, 0);
}
Anything incorrect stand out and should it work with the shield base? Any help would be much appreciated.