Netduino home hardware projects downloads community

Jump to content


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.
Photo

Stefans Toolbox and MotorShield. Does not run!


  • Please log in to reply
24 replies to this topic

#1 Moskus

Moskus

    Advanced Member

  • Members
  • PipPipPip
  • 132 posts
  • LocationNorway

Posted 08 March 2012 - 12:17 PM

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...

#2 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 08 March 2012 - 12:21 PM

Hi Moskus,

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.
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#3 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 08 March 2012 - 03:35 PM

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.
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#4 Moskus

Moskus

    Advanced Member

  • Members
  • PipPipPip
  • 132 posts
  • LocationNorway

Posted 09 March 2012 - 01:21 PM

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. Posted Image

#5 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 09 March 2012 - 01:25 PM

It's strange cause I don't see HBridge anywhere...
Toolbox.NETMF.Hardware.HBridge source :)

> 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?

"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#6 Moskus

Moskus

    Advanced Member

  • Members
  • PipPipPip
  • 132 posts
  • LocationNorway

Posted 11 March 2012 - 07:22 PM

>It's strange cause I don't see HBridge anywhere...
Toolbox.NETMF.Hardware.HBridge source :)


Then what is going on? I just downloaded the latest version. Posted Image

> 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).

2. I'll do that right away. :)

#7 Moskus

Moskus

    Advanced Member

  • Members
  • PipPipPip
  • 132 posts
  • LocationNorway

Posted 11 March 2012 - 07:45 PM

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... Posted Image

#8 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 12 March 2012 - 08:50 AM

So I let the computer start up, removed the motor shield and tried again. This time I got a blue screen... Posted Image

:(

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?
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#9 Moskus

Moskus

    Advanced Member

  • Members
  • PipPipPip
  • 132 posts
  • LocationNorway

Posted 12 March 2012 - 01:49 PM

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... Posted Image

#10 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 12 March 2012 - 01:51 PM

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... Posted Image

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.
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#11 Moskus

Moskus

    Advanced Member

  • Members
  • PipPipPip
  • 132 posts
  • LocationNorway

Posted 18 March 2012 - 06:55 PM

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?

Attached Files



#12 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 19 March 2012 - 07:29 AM

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.

Attached Files


"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#13 Moskus

Moskus

    Advanced Member

  • Members
  • PipPipPip
  • 132 posts
  • LocationNorway

Posted 19 March 2012 - 06:23 PM

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.

That solution worked! What did you do (I see the HBridge now)?
(And what did I do wrong?)

THANK YOU! :D

EDIT: The motors seems to be running when I connect the power until the program starts. Is there any way to prevent this?

#14 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 19 March 2012 - 06:25 PM

That solution worked! What did you do (I see the HBridge now)?
(And what did I do wrong?)

I updated the DLLs to the latest version (and the be/le versions), just to be sure, and removed the obj and bin folders.
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#15 Moskus

Moskus

    Advanced Member

  • Members
  • PipPipPip
  • 132 posts
  • LocationNorway

Posted 19 March 2012 - 06:30 PM

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?

#16 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 19 March 2012 - 06:48 PM

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?

http://forums.netdui...uring-power-up/
Perhaps that helps?
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#17 Moskus

Moskus

    Advanced Member

  • Members
  • PipPipPip
  • 132 posts
  • LocationNorway

Posted 19 March 2012 - 07:46 PM

Well, at least it tells me that the problem is not easy to solve... ;)

#18 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 19 March 2012 - 07:54 PM

Well, at least it tells me that the problem is not easy to solve... ;)

Indeed ;)
Glad I could help you come this far though!
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#19 Moskus

Moskus

    Advanced Member

  • Members
  • PipPipPip
  • 132 posts
  • LocationNorway

Posted 21 March 2012 - 07:27 PM

Indeed ;)
Glad I could help you come this far though!

I'll make it work somehow! :)

A big thanks to you! :D

#20 alhardy

alhardy

    New Member

  • Members
  • Pip
  • 8 posts
  • LocationSydney, Australia

Posted 28 May 2012 - 10:28 AM

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.

Allan




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.