Skip to content

Instantly share code, notes, and snippets.

@treeherder
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save treeherder/9317034 to your computer and use it in GitHub Desktop.

Select an option

Save treeherder/9317034 to your computer and use it in GitHub Desktop.
control l298d breakout module
typedef struct return_data current;
struct return_data
{
uint32_t c_1; //current one
uint32_t c_2; //current two
//quadrature encoder data can come in here
//accelerometer data?
};
uint32_t forward(return_data *curr)
{
uint32_t _c1;
uint32_t _c2;
_c1 = 1;
_c2 = 1;
digitalWrite(M1A,HIGH); //right wheel channel 1
digitalWrite(M1B,HIGH); //right wheel channel 2
digitalWrite(EN1A,HIGH); //right enable channel 1
digitalWrite(EN1B,HIGH); //right enable channel 2
digitalWrite(M2A,LOW); //left wheel channel 1
digitalWrite(M2B,LOW); //left wheel channel 2
digitalWrite(EN2A,HIGH); //left enable channel 1
digitalWrite(EN2B,HIGH); //left enable channel 2
curr -> analogRead(C1) = _c1;
curr -> analogRead(C2) = _c2; // check current for both wheels
return (0);
}
@gskielian
Copy link

The code looks great!

@gskielian
Copy link

We'll need to add this on line 69 -- could be crucial

69 +  digitalWrite(M1A,LOW); //right wheel channel 1  
70     digitalWrite(M1B,LOW); //right wheel channel 2
71     digitalWrite(EN1A,HIGH); 

@gskielian
Copy link

The above edit in a gist

https://gist.github.com/gskielian/9344151

will work on macros

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment