allanhurst:
For example - I needed sines and cosines for a recent project, so I put the values for each degree scaled 0..255 into arrays...
unsigned char sinA [] =
{0, 4, 8, 13, 17, 22, 26, 31, 35, 39, 44, 48, 53, 57, 61, 65,
70, 74, 78, 83, 87, 91, 95, 99, 103, 107, 111, 115, 119, 123,
127, 131, 135, 138, 142, 146, 149, 153, 156, 160, 163, 167,
170, 173, 177, 180, 183, 186, 189, 192, 195, 198, 200, 203,
206, 208, 211, 213, 216, 218, 220, 223, 225, 227, 229, 231,
232, 234, 236, 238, 239, 241, 242, 243, 245, 246, 247, 248,
249, 250, 251, 251, 252, 253, 253, 254, 254, 254, 254, 254, 255};
unsigned char cosA [] =
{255, 254, 254, 254, 254, 254, 253, 253, 252, 251, 251, 250,
249, 248, 247, 246, 245, 243, 242, 241, 239, 238, 236, 234,
232, 231, 229, 227, 225, 223, 220, 218, 216, 213, 211, 208,
206, 203, 200, 198, 195, 192, 189, 186, 183, 180, 177, 173,
170, 167, 163, 160, 156, 153, 149, 146, 142, 138, 135, 131,
127, 123, 119, 115, 111, 107, 103, 99, 95, 91, 87, 83, 78,
74, 70, 65, 61, 57, 53, 48, 44, 39, 35, 31, 26, 22, 17, 13,
8, 4, 0};
eg The sines and cosines are for 0..90 degrees - if I were to send each successive value to an 8-bit DAC at equal intervals I'd get the 1st 90 degrees of a sin/cos waveform in 90 steps.
I didn't need -ve values - but that's detail...
regards
Allan
I see, thanks for the information.
I have converted some waves to 0-255 values.
How does this translate over to programming it into an arduino. Like for example, this is one for an arduino due signal generator...
'// Triangular wave
{
0x44, 0x88, 0xcc, 0x110, 0x154, 0x198, 0x1dc, 0x220, 0x264, 0x2a8,
0x2ec, 0x330, 0x374, 0x3b8, 0x3fc, 0x440, 0x484, 0x4c8, 0x50c, 0x550,
0x594, 0x5d8, 0x61c, 0x660, 0x6a4, 0x6e8, 0x72c, 0x770, 0x7b4, 0x7f8,
0x83c, 0x880, 0x8c4, 0x908, 0x94c, 0x990, 0x9d4, 0xa18, 0xa5c, 0xaa0,
0xae4, 0xb28, 0xb6c, 0xbb0, 0xbf4, 0xc38, 0xc7c, 0xcc0, 0xd04, 0xd48,
0xd8c, 0xdd0, 0xe14, 0xe58, 0xe9c, 0xee0, 0xf24, 0xf68, 0xfac, 0xff0,
0xfac, 0xf68, 0xf24, 0xee0, 0xe9c, 0xe58, 0xe14, 0xdd0, 0xd8c, 0xd48,
0xd04, 0xcc0, 0xc7c, 0xc38, 0xbf4, 0xbb0, 0xb6c, 0xb28, 0xae4, 0xaa0,
0xa5c, 0xa18, 0x9d4, 0x990, 0x94c, 0x908, 0x8c4, 0x880, 0x83c, 0x7f8,
0x7b4, 0x770, 0x72c, 0x6e8, 0x6a4, 0x660, 0x61c, 0x5d8, 0x594, 0x550,
0x50c, 0x4c8, 0x484, 0x440, 0x3fc, 0x3b8, 0x374, 0x330, 0x2ec, 0x2a8,
0x264, 0x220, 0x1dc, 0x198, 0x154, 0x110, 0xcc, 0x88, 0x44, 0x0
}'
How do I go from like 6, 12, 24 to like 0x44, 0xcc etc?