NeonMika / Markus VV. - Viewing Profile: Likes - Netduino Forums - Page 2
   
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.

NeonMika / Markus VV.

Member Since 30 Sep 2011
Offline Last Active Oct 20 2015 11:25 AM
****-

#22732 PWM SetPulse Parameters

Posted by NeonMika / Markus VV. on 12 January 2012 - 05:20 PM

Hi,


I have read many different information, and do not have an osciloscope near.. so can anyone please help me clarify what is the unit of time expected in the period an pulse parameters of the PWM SetPulse method? Milliseconds? Microsendons? clock pulses?


AFAIK it is microseconds... I've read examples on servo driving where the servos needed a 20ms duration signal and to turn it to middle position it needed an "on-time" of 1,3 ms... it worked with the following command:
servoLen.SetPulse(20000, 1300);
Greets, Markus


#22617 Communicating with my Netduino Plus

Posted by NeonMika / Markus VV. on 09 January 2012 - 04:45 PM

The learning curve isn't that steep.
So there are some things you should know "about the basics":

You have one "ListeningSocket"... This sockets waits for incoming requests (server side / Netduino)
You do this by creating a Socket with the following syntax:
_ListeningSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
Now tell the socket "where he belongs to". He should listen to all incoming IP's that request a specific port (i don't know how much you know about TCP/IP... To start you can imagine a port as a application (in this case your Netduino server app)
_ListeningSocket.Bind(new IPEndPoint(IPAddress.Any, portNumber));
Now start listening. The number tells the Socket, how many request will be queued.
_ListeningSocket.Listen(10);

I will now short my own webserver code to explain the main things of sockets:

while (true)
        	{
            	try
            	{
                	using (Socket clientSocket = _ListeningSocket.Accept())
                	{
                    	int availableBytes = 0;

                    	//if client connects but sends no data in the first milliseconds
                    	for (int receiveTry = 0; receiveTry < 20; receiveTry++)
                    	{
                        	if ((availableBytes = clientSocket.Available) == 0)
                            	Thread.Sleep(1);
                        	else
                            	break;
                    	}

                    	int newAvBytes;

                    	//if not all incoming bytes were received by the socket
                    	do
                    	{
                        	newAvBytes = clientSocket.Available - availableBytes;

                        	if (newAvBytes == 0)
                            	break;

                        	availableBytes += newAvBytes;
                        	newAvBytes = 0;
                        	Thread.Sleep(5);
                    	} while (true);

                   	//all bytes received------------------------------

                    	//ignore requests that are too big
                     	byte[] buffer = new byte[availableBytes];
                     	int readByteCount = clientSocket.Receive(buffer, availableBytes, SocketFlags.None);

                     	//Now do everything you want to do with your byte-array

                    	clientSocket.Close();
                	}
            	}
            	catch (Exception ex)
            	{
            	}
}

You said you understand what this code does? You get a clientSocket if someone connects. This socket will be kept open till the server or the client closes it. This example is based on the assumption, that the socket is closed after every sent statement. (see clientSocket.Close();)
To send data back to the client you can use clientSocket.Send()...
If you want to keep the connection open you have to check if the client still is connected. I'm not that sure how to check this. As far as i know, read "blocks" the code execution if the client is still active and no data is sent and will return "0" if the client disconnected...

Greets, Markus


#20317 NeonMika.Webserver

Posted by NeonMika / Markus VV. on 07 November 2011 - 04:42 PM

NeonMika.Webserver @ http://neonmikawebserver.codeplex.com/


Introducing

Hey guys,

NeonMika.Webserver is an pre-setup and easy to extend webserver. With minimal (to no) code you can achieve great results controlling your Netduino+, accessing and uploading files and more!

 

It's supports:
- SD card access

- Controlling your Netduino using existing methods like setPWM or setDigitalPinState (see full list below)

- Adding your own webservice-like methods so you can expand NeonMika.Webserver to your own needs for every project.

How easy is it?

Server WebServer = new Server PinManagement.OnboardLED, 80, false, "192.168.0.200", "255.255.255.0", "192.168.0.1", "NETDUINOPLUS");

The parameter for setup are: The OnboardLED, Port, DHCPenable, ipAdress, subnetMask, gateway, name.
You don't need anything more to run it!

 

At http://neonmikawebse...m/documentation you can find a complete documentation on how to set up the server and how to expand it.

 

What methods are already implemented?

 

Here is a list with all pre-coded webmethods you can use within your browser or any other application to communicate with your Netduino:

 

echo (Returns the submitted value)
-> netduinoplus/echo?value=[a-Z]

switchDigitalPin (Switches the selected pin from true to false and vis-a-vis)
-> netduinoplus/switchDigitalPin?pin=[0-13]

setDigitalPin (Set the selected digital pin to the selected state)
-> netduinoplus/setDigitalPin?pin=[0-13]&state=[true|false]

pwm (Set the PWM of the pin to the submitted period & duration
-> netduinoplus/pwm?pin=[5|6|9|10]&period=[int]&duration=[int]

getAnalogPinValue (Return the value of the selected analog pin)
-> netduinoplus/getAnalogPinValue?pin=[0-5]

getDigitalPinState (Returns your selected pin's state (on / off))
-> netduinoplus/getDigitalPinState?pin=[0-13]

getAllAnalogPinValues (Return the value for each analog pin)
-> netduinoplus/getAllAnalogPinValues

getDigitalPinState (Returns the state for each digital pin)
-> netduinoplus/getAllDigitalPinStates

getAllPWMValues (Returns the values for all PWM ports)
-> netduinoplus/getAllPWMValues

fileUpload (Uploads a file to the path on the SD card via POST. You have to write the file-data (bytes) into the POST body)
-> netduinoplus/upload?path=[a-Z]

AND FOR SURE:
File and directory response
Just type in netduinoplus/[pathtomyfile] and you can view / download your file. If the given path is a directory, a directory view will be returned

 

Some examples:

 

Example commands (can be executed with browser):

Show file directory:

Access file:

Download & Documentation:

http://neonmikawebserver.codeplex.com/

http://neonmikawebse...m/documentation

 

Project & Videos
 

Controlling your Netduino+ with Android phone

Thanks to skarphedinnos for this great video about controlling Pins and PWM with NeonMika.Webserver & Android!

http://www.youtube.c...h?v=Q5T7TQsOf-w

 

Home brewery

Thanks to Coding Smackdown for using NeonMika.Webserver in his awesome beer brewing Project!

http://diybrewery.com/

 

N+2 aquarium controller

Thanks to H07R0D!

http://forums.netdui...roller/?p=34544

 

--------------------------------------------------------

I appreciate every kind of response. I want this to help the community, so I hope the communty will help me to get this project better and better

Thanks and greets,

Markus
 

 

-----------------------------------------------------------------

-----------------------------------------------------------------

Changelog:

- Index page(8.11.2011)
- Screenshot ofecho, switchPin and index page (8.11.2011)
- JSON support(30.11.11)
- PWM(30.11.11)
- getAnalogPinValue and getDigitalPinState (30.11.2011)
- Examples(30.11.2011)
- FileResponseimproved (15.3.2012)
- Changed indexpage (15.3.2012)
- Nested XMLsupport (28.4.2012)
- Example method for nested XML -> see MultipeXML(28.4.2012)
- Code cleanup(28.4.2012)
- POST working!(22.11.2012)
- File upload(22.11.2012)
- Better XML(22.11.2012)
- Choosing between DHCP and fixed IP (22.11.2012)
- Return filelist from directory (Directory view) (22.11.2012)

- Some changes to the code (Somewhere here between :P)

- Videos (13.3.2013)

- Nameservice (28.3.2013)
- Server code refactor and restructure (28.3.2013)
- Index page (28.3.2013)
- New webserver methods (28.3.2013)
--- GetAllPWM (Returns duration and period for all PWM pins)
--- GetAllDigitalPinStates (Returns the state for all digital pins)
--- GetAllAnalogPinValues (Returns the value for all analog pins)
- NeonMika.Webserver.ClientLibrary Version 0.1 (28.3.2013)

- NeonMika.Webserver V1.2

--- Fixed POST file upload

--- Fixed SD card view

Attached Files




#19961 File Download Via Ethernet

Posted by NeonMika / Markus VV. on 29 October 2011 - 01:36 PM

Hi Markus,
I would greatly appreciate a look at your webserver code... It's helpfull guys like you thank get us old guys hooked on new toys :rolleyes:


Yeah, I'm working on it. :P
I developed an PC version and just finnished porting it to .NETMF. But I'm facing a problem at the moment (http://forums.netdui...9959#entry19959)
When it's finnished i will post a link to codeplex where you can download the full source.
I will message you via PM if you want. :)

Greets Markus


#19474 File Download Via Ethernet

Posted by NeonMika / Markus VV. on 20 October 2011 - 10:05 PM

If you could wait till the end of the weekend, i will upload my webserver project. With it you can access your Netduino via your browser and I try to build it easy extendable, so that you could code just a little method and be able to access your pins on the netduino through the browser for example. But due to school and work i don't have time to finish it till saturday. Code will be published then =) Greets Markus




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.