Using SD Cards with...
 
Notifications
Clear all

Using SD Cards with Arduino - Record Servo Motor Movements

84 Posts
6 Users
1 Likes
7,664 Views
(@robomaster)
Member
Joined: 3 years ago
Posts: 36
 

I now got it working in stopping the Playback Mode I also added some Nerpixel LEDs to indicate when in Record / Playback Modes. Again Thank You for all your help. Sometimes it takes another pair of eyes to see something I missed.


   
ReplyQuote
(@robomaster)
Member
Joined: 3 years ago
Posts: 36
 

I look at that and now have it all working but I am having a problem coming up with a good approach to it get it to do four channels of record/playback. Any Ideas?

 


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2519
 

@robomaster 

It's not clear what 4 values you wish to record.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@robomaster)
Member
Joined: 3 years ago
Posts: 36
 

The program as it sits right is reading A0 which is connected to a potentiometer that sends a 0 volt to 5volt voltage to it which is mapped to 0 to 180 degrees which are then recorded to the SD Card. So I am just doing one channel recording I need to expand this to record four analog channels to the SD Card. I am not sure which way would work the best.  I simply need to read A0 to A3 then map it to 0 to 180 degrees record and playback to the SD Card.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2519
 

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@robomaster)
Member
Joined: 3 years ago
Posts: 36
 

I thank you for your help I like the use of the subroutines. I need to see the servos moving in the record subroutines.  I will try this out and let you know if I have any questions about it. Again thank you for your help.


   
ReplyQuote
(@robomaster)
Member
Joined: 3 years ago
Posts: 36
 

 

Here is a version with what you suggested added to it.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2519
 
Posted by: @robomaster

 

Here is a version with what you suggested added to it.

How do you figure that ? It appears to be using a servo to scan distance with something like an HC-SR04 at 1 degree intervals from 15 to 165 degrees and ten the same backwards.

It doesn't even use an SD card.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@robomaster)
Member
Joined: 3 years ago
Posts: 36
 

No, what I am saying if you look at the single-channel code in the record mode it moves the servo as well as records it to the SD Card. I am sorry if I miss lead you.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2519
 

@robomaster 

 

My apologies, you didn't mislead me, I appear to have been looking at the wrong sketch.

I've just brought yours up and am looking at it now.

It looks to me that in Record() you have an empty string (called dataString) which you still write as a String into the file despite the fact that you've never assigned a value to it.

Am I still looking at the wrong sketch ?

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@robomaster)
Member
Joined: 3 years ago
Posts: 36
 
Complie

 

It is not compiling here and an image of the error message I am getting. I am in the process of making the changes to the code that you suggested. Again thank you for all your help.

 


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2519
 

@robomaster 

The error is because you have declares the array with the name "myServos" while I used the array name "servos". You have to pick one name and stick with it and the compiler will be happy.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@robomaster)
Member
Joined: 3 years ago
Posts: 36
 

Let me work on it and get back to you on it.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2519
 

@robomaster 

OK

Three other things and some general comments ...

1) if you click on the "Reply" button on the forum, it adds the name of the person you're replying to which not only helps when you're taking with a bunch of people but also sends out  an email to the person so that they know you've replied. Otherwise, we just have to "notice" by perusing the list of new posts.

2) you should think about getting rid of some of the code that's been commented out. It's interfering with understanding the active code.

3) You should work on a consistent indentation scheme. It really helps when code is indented in loops, conditionals, subroutines and so forth and the closing bracket is at the same level. Doing so will make it much easier for us (and eventually you) to look at your code and understand what parts go together.

I know this is all new to you and you're exploding code from the middle, but try to organize the code blocks one at a time, as you work on each one. You can do the major tidy up when everything works.

Also, I gather that you're relatively new to writing code.So let me suggest that the best way to work on a complicated project is to try to get the first part working (more or less ignoring the rest of the project) and then, when it's compiled and tested, move on to the next part.

The reason for doing this is that if you try to do everything at once, you'll get an explosion of errors all over the place and it's difficult to figure out where to start cleaning them up. If, however, you only write the code for, say, printing the data array to the serial monitor; then loading the data array with the servo (which you can know test by using your shiny new code which prints to the serial monitor); then writing the data to the file, then reading the data from the file (which, again you can use your recently constructed display code) and so on.

That way, all the errors are likely to be "local" to the code you're writing so they should be easier to find and easier to fix. You may notice that the above also fits in nicely with organizing common sets of operations into subroutines.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@robomaster)
Member
Joined: 3 years ago
Posts: 36
 

 

20210922 212834

Will,

I have been going over the new functions and I am not quite sure how to modify the record and playback functions so I can use them. I guess I don't quite understand your basic Idea. Here is the current code.

Here is an image of the mini programming console

 

Thank You for all your help.

 

Robomaster


   
ReplyQuote
Page 2 / 6