Pages: [1]   Go Down
Author Topic: Programming outside ssource WiFiShield_library to Arduino programming  (Read 676 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Trying to program to arduino with a new program that came with the WiFi Shield. Downloaded the program but can't get it to work on the arduino source code screen can anyone talk me through a procedure to make it work  thanks  Michael
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 613
Posts: 49310
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Downloaded the program but can't get it to work on the arduino source code screen
What does this mean? What code?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry was trying to download WiFiShield_library to arduino but keep losing the library and can't get it to download to arduino sketch  if that makes any more sense please help   Michael
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 613
Posts: 49310
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
if that makes any more sense
Sorry, no it doesn't.

Quote
was trying to download WiFiShield_library to arduino
I don't understand. You use the library in code that gets compiled, linked, and uploaded to the Arduino. The library itself doesn't get downloaded to the Arduino.

Quote
but keep losing the library
Libraries don't go away.

Quote
and can't get it to download to arduino sketch
What sketch?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


wifi shield library in computer under my blink sketches but when i try to use the library compiler doesnt recognize the library is there any way i can get it to recognize the wifi shield library   also trying to use the arduino and wifi shield to communicate to pc information from a wind turbine that it is connected to   if any one has any suggestion i would appreciate it  michael
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Getting compiling errors even when i use the examples from the libraries. can any one give me some suggestions to solve this problem.   MIchael
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 613
Posts: 49310
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Getting compiling errors even when i use the examples from the libraries. can any one give me some suggestions to solve this problem.
Yes. Fix the code.

Since you haven't posted the code or the error messages, that's the best we can do.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry about that forgot to send code. Decided to use Ethernet shield, got it to upload to Arduino with Ethernet shield. Not sure if it is sending info back to computer. When I upload the code it shows as being right (No errors) but when I disconnect the USB and connect the Ethernet cable i don't get any info on PC screen or serial monitor. Also trying to get wireless router involved, any ideas how.
here is the code, can you look it over and see if you can figure out why it isn't sending the info back to PC?  Thanks  Michael

/*
 *    The purpose of this program is too monitor the voltage of a battery and depending on the voltage generator.
 *     The controller needs to handle a wide voltage range and a wide current range if connected to a turbine
 *    of varying speed. The speed can vary greatly and therefore the out will have to be carefully monitored.
 *
 *    The controller will have the following states:
 *        - Battery voltage below 14.0v       :    charge the battery
 *        - Battery voltage 14.0v or above    :    dump the turbine generator power to a dummy load
 *
 */
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0x90, 0xA2, 0XDA, 0X0D, 0X8B, 0X11 };  //MAC ADDRESS FOR ARDUINO//
byte ip[] = { 192, 168, 1, 1 }; //ip address//

// Voltage divider constants (ohms)
const int    VD_R3                    =    10000;
const int    VD_R4                    =    1000;

// Manual buttons
const int    CHARGE_BUTTON            =    2; // DIN
const int    DUMP_BUTTON              =    3; // DIN

// LED displays
const int    STATUS_LED               =    13; // DOUT

// Battery charging
const int    BATTERY_MONITOR_PIN      =    0; // AIN
const int    INSTRUCTION_PIN          =    6; // DOUT
const float  BAT_VMIN                 =    11.9;
const float  BAT_VMAX                 =    14.0;

// Turbine RPM monitoring
const int    RPM_MONITOR_PIN          =    1; // AIN

// Other
const int    DELAY_TIME               =    32; // 32 default

// Program variables
bool manual = false;
bool charging = false;
EthernetClient client;
void setup()
{
    pinMode(STATUS_LED, OUTPUT);
    pinMode(CHARGE_BUTTON, INPUT);
    pinMode(DUMP_BUTTON, INPUT);
    pinMode(INSTRUCTION_PIN, OUTPUT);
   
    digitalWrite(STATUS_LED, HIGH);
   
    Serial.begin(115200);
    if (Ethernet.begin(mac) == 0){
      Serial.println("Failed to configure Ethernet using DHCP");
      for(;smiley-wink
        ;
    }
    Serial.println(Ethernet.localIP());
}

void loop()
{
    int vin = analogRead(BATTERY_MONITOR_PIN);
    float voltage = calculateBatteryVoltage(vin);
   
    int rin = analogRead(RPM_MONITOR_PIN);
    int rpm = calculateRPM(rin);
   
    if (chargeButtonDown())
    {
        manual = true;
        charge();
    }
    else if (dumpButtonDown())
    {
        manual = true;
        dump();
    }
   
    if (!manual)
    {
        if (voltage < BAT_VMAX)
            charge();
        else
            dump();
    }   
   
    manual = false;
   
    delay(DELAY_TIME);
}

float calculateBatteryVoltage(int vin)
{
    float resconst;
   
    if (VD_R3 == 0 || VD_R4 == 0)
        resconst = 1.0;
    else
        resconst = ((VD_R3 + VD_R4) / VD_R4);
   
    return (5.0 / 1023.0) * resconst * vin;
}

int calculateRPM(int rin)
{
    // this function will determine the rpm from an analog value
    // for now just return value passed
    return rin;
}

inline bool chargeButtonDown() { return (digitalRead(CHARGE_BUTTON) == HIGH) ? true : false; }

inline bool dumpButtonDown() { return (digitalRead(DUMP_BUTTON) == HIGH) ? true : false; }

inline void charge() { digitalWrite(INSTRUCTION_PIN, HIGH); charging = true; }

inline void dump() { digitalWrite(INSTRUCTION_PIN, LOW); charging = false; }

inline bool getState() { return (charging) ? true : false; }

void SerialWriteData(float voltage, int rpm)
{
    Serial.print("Voltage: ");
    Serial.print(voltage);
    Serial.print("V");
    Serial.print("RPM: ");
    Serial.print(rpm);
    // TO DO: show whether charging or not
}
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 613
Posts: 49310
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Your copy of the code has smiley faces?

There is a reason that you are supposed to use the # icon when posting code. Modify your post. Delete the code. Press the # icon, and insert the code again.

Before you hit save, start at the top, and look at the questions. Make sure that the ratio of answers to questions is correct.
Logged

Pages: [1]   Go Up
Jump to: